% Chapter 11, Example 11.1, Fig.11.1
% Eric Dubois, updated 2018-12-24
% Plot lattice and sublattice
% Required functions:  Lattice_Points_2d, ds2nfu
clear all
close all

%sampling matrices and portion of R^2 to plot
VL = [2 0; 0 1.6];
VG = [2 1; 0 0.8];
UL = [0 0]';
LR = [5 3.2]';

%get the points of the lattices in the desired region 
xoutL = Lattice_Points_2d(VL,UL,LR);
xoutG = Lattice_Points_2d(VG,UL,LR);
%create the plot

figure

%plot the points
points = plot(xoutL(:,1),xoutL(:,2),'k.',xoutG(:,1),xoutG(:,2),'ks');
points(1).MarkerSize= 9;
points(2).MarkerSize= 8;
axis equal
axis off
set(gca,'ydir','reverse'); 

hold on

%create the axes
%x axis from 0 to +5.5
[xaxx,xaxy] = ds2nfu([0.07 5.3], [3.15 3.15]);
annotation('arrow',xaxx,xaxy,'headlength',5,'headwidth',5);
%y axis from 0 to 4
[yaxx,yaxy] = ds2nfu([0.07 0.07],[3.15 -.4]);
annotation('arrow',yaxx,yaxy,'headlength',5,'headwidth',5);
text(5.3,-.2,'\itx')
text(-0.2, 3.5, '\ity')

% plot x-axis ticks and labels
plot([1 1],[-.05 .05],'k')
plot([3 3],[-.05 .05],'k')
plot([5 5],[-.05 .05],'k')
text(.95,-.15,'\itX')
text(1.95,-.15,'2\itX')
text(2.95,-.15,'3\itX')
text(3.95,-.15,'4\itX')
text(4.95,-.15,'5\itX')
%plot y-axis ticks and labels
plot([-.05 .05],[.8 .8],'k')
plot([-.05 .05],[2.4 2.4],'k')
text(-.17,.8,'\itY')
text(-.29,1.6,'2\itY')
text(-.29,2.4,'3\itY')
text(-.29,3.2,'4\itY')

set(gcf,'Color',[1 1 1]);
