% Chapter 11, Example 11.2, Fig.11.5
% Eric Dubois, updated 2019-01-14
% Upsampling of rectangularly sampled signal by a factor of 4 in each dimension:
% frequency domain view.
% Required functions:  Lattice_Points_2d, ds2nfu
clear all
close all

%sampling matrices of reciprocal lattices and portion of R^2 to plot
VLs = [0.25 0; 0 0.25];
VGs = [1 0; 0 1];
UL = [-0.5 -0.5]';
LR = [0.5 0.5]';

%get the points of the lattices in the desired region 
xoutLs = Lattice_Points_2d(VLs,UL,LR);

%create the plot

figure

%plot the points
points = plot(xoutLs(:,1),xoutLs(:,2),'k.');
points(1).MarkerSize= 9;
axis equal
axis off
set(gca,'ydir','reverse'); 

hold on

%plot the unit cells
rectangle('Position',[-.5,-.5,1,1]);
rectangle('Position',[-.125,-.125,.25,.25]);

%label unit cells
strPL = '$$\mathcal{P}_{\Lambda^*}$$';
text(.15,-.15,strPL,'Interpreter','latex');
strPG = '$$\mathcal{P}_{\Gamma^*}$$';
text(.55,-.4,strPG,'Interpreter','latex');
[aGx,aGy] = ds2nfu([.145 .08],[.12 .09]);
annotation('arrow',aGx,aGy,'headlength',4,'headwidth',4);
[aLx, aLy] = ds2nfu([.55 .45],[.4 .35]); 
annotation('arrow',aLx,aLy,'headlength',4,'headwidth',4);

% Label filter values
text(-.1,-.1,'16');
text(-.4,-.2,'0');

%create the axes
%u axis from -.6 to .6
[xaxx,xaxy] = ds2nfu([-.6 .65], [0 0]);
annotation('arrow',xaxx,xaxy,'headlength',5,'headwidth',5);
%y axis from -.6 to .6
[yaxx,yaxy] = ds2nfu([0.0 0.0],[.55 -.6]);
annotation('arrow',yaxx,yaxy,'headlength',5,'headwidth',5);
text(.6,-0.05,'\itu');
text(.65,-0.05,'(c/opx)');
text(0.03, .55, '\itv');
text(.08,.55,'(c/opx)');

%insert axis labels
text(0.23,.05,'0.25');
text(0.52,.05,'0.5');
text(-0.29,.05,'-0.25');
text(-0.59,.05,'-0.5');
text(0.02,.25,'0.25');
text(0.02,.47,'0.5');
text(.02,-.25,'-0.25');
text(.02,-.47,'-0.5');

set(gcf,'Color',[1 1 1]);