% Chapter 11, Fig.11.12
% Eric Dubois, updated 2019-01-15
% Plot lattices for sampling structure conversion example
% Required functions:  Lattice_Points_2d, ds2nfu
clear all
close all

%sampling matrices and portion of R^2 to plot
VL1 = [1 0; 1 2];
VL2 = [2 1; 0 2];
VL3 = [1 0; 0 1];
UL = [0 0]';
LR = [4 4]';

%get the points of the lattices in the desired region 
xoutL1 = Lattice_Points_2d(VL1,UL,LR);
xoutL2 = Lattice_Points_2d(VL2,UL,LR);
xoutL3 = Lattice_Points_2d(VL3,UL,LR);
%create the plot

figure

%plot the points
points = plot(xoutL1(:,1),xoutL1(:,2),'k.',xoutL2(:,1),xoutL2(:,2),'ks',...
    xoutL3(:,1),xoutL3(:,2),'k.');
points(1).MarkerSize= 11;
points(2).MarkerSize= 8;
points(3).MarkerSize= 6;
axis equal
axis off
set(gca,'ydir','reverse'); 

hold on

%create the axes
%x axis from 0 to +4.5
[xaxx,xaxy] = ds2nfu([-0.2 4.5], [3.95 3.95]);
annotation('arrow',xaxx,xaxy,'headlength',5,'headwidth',5);
%y axis from 0 to 4
[yaxx,yaxy] = ds2nfu([0.05 0.05],[4.15 -.4]);
annotation('arrow',yaxx,yaxy,'headlength',5,'headwidth',5);
text(4.5,-.2,'\itx')
text(-0.2, 4.3, '\ity')

% plot x-axis ticks and labels
plot([1 1],[-.05 .05],'k')
plot([3 3],[-.05 .05],'k')
text(.95,-.17,'1')
text(1.95,-.17,'2')
text(2.95,-.17,'3')
text(3.95,-.17,'4')
%plot y-axis ticks and labels
plot([-.05 .05],[1 1],'k')
plot([-.05 .05],[3 3],'k')
text(-.17,1,'1')
text(-.29,2,'2')
text(-.29,3,'3')
text(-.29,4,'4')
% 

set(gcf,'Color',[1 1 1]);
