% Chapter 13, Fig.13.4
% Eric Dubois, updated 2019-01-15
% Required functions:  Lattice_Points_2d, ds2nfu
% Plot point of a lattice and a sublattice
clear all
close all

%sampling matrices and portion of R^2 to plot
VL = [.9 1.4; .3 -.5];
VG = [.4 1.4; 1.1 -.5];
UL = [-3 -2]';
LR = [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
plot(xoutL(:,1),xoutL(:,2),'ko',xoutG(:,1),xoutG(:,2),'kx')
axis equal
axis off
set(gca,'ydir','reverse'); 
axis([UL(1) LR(1) UL(2) LR(2)])
hold on
%create the axes
%x axis from -3 to +3
[xaxx xaxy] = ds2nfu([-3 3], [0 0]);
annotation('arrow',xaxx,xaxy,'headlength',5,'headwidth',5);
%y axis from -2 to +2
[yaxx yaxy] = ds2nfu([0 0],[2 -2.2]);
annotation('arrow',yaxx,yaxy,'headlength',5,'headwidth',5);
text(3,-.2,'\itx')
text(0.2, 2.1, '\ity')

%plot and label the basis vectors
[v1x v1y] = ds2nfu([0 .95*VG(1,1)],[0,-.95*VG(2,1)]);
annotation('arrow',v1x,v1y,'headlength',5,'headwidth',5);
[v2x v2y] = ds2nfu([0 .95*VG(1,2)],[0,-.95*VG(2,2)]);
annotation('arrow',v2x,v2y,'headlength',5,'headwidth',5);
text(1.15*VG(1,1), 1.1*VG(2,1), '{\bfv}_{\Gamma,1}'); 
text(1.1*VG(1,2), 1.1*VG(2,2), '{\bfv}_{\Gamma,2}');  

%plot x-axis tick and label
plot([1 1],[-.05 .05],'k')
text(1,-.1,'\itX')
%plot y-axis tick and label
plot([-.05 .05],[1 1],'k')
text(.1,1,'\itX')

set(gcf,'Color',[1 1 1]);