% Chapter 11, Example 11.1, Fig.11.2
% Eric Dubois, updated 2018-12-24
% Plot reciprocal lattice and reciprocal sublattice and spectral support of
% signal under upsampling
% Required functions:  Lattice_Points_2d, ds2nfu
clear all
close all

%sampling matrices of reciprocal lattices and portion of R^2 to plot
VLs = [0.5 0; 0 0.625];
VGs = [0.5 0; -0.625 1.25];
UL = [-1.5 -1.25]';
LR = [1.5 1.25]';

%get the points of the lattices in the desired region 
xoutLs = Lattice_Points_2d(VLs,UL,LR);
xoutGs = Lattice_Points_2d(VGs,UL,LR);
%create the plot
%set the plot size and font
figure

%plot the points
points = plot(xoutLs(:,1),xoutLs(:,2),'k.',xoutGs(:,1),xoutGs(:,2),'ks');
points(1).MarkerSize= 9;
points(2).MarkerSize= 8;
axis equal
axis off
set(gca,'ydir','reverse'); 

%plot circles on each reciprocal lattice point
%black circles on the points of Gamma*
radii = 0.23*ones(size(xoutGs,1),1);
viscircles(xoutGs,radii,'Color','k','LineWidth',1);
%red dashed circles on the points of Lambda*  not in Gamma*
xoutLsnotGs = setdiff(xoutLs,xoutGs,'rows');
radii_2 = 0.23*ones(size(xoutLsnotGs,1),1);
viscircles(xoutLsnotGs,radii_2,'Color','r','LineWidth',2,'LineStyle',':');

hold on

%create the axes
%u axis from -1.85 to +1.95
[xaxx,xaxy] = ds2nfu([-1.85 1.95], [0 0]);
annotation('arrow',xaxx,xaxy,'headlength',5,'headwidth',5);
%y axis from -1.6 to 1.7
[yaxx,yaxy] = ds2nfu([0.0 0.0],[1.6 -1.7]);
annotation('arrow',yaxx,yaxy,'headlength',5,'headwidth',5);
text(1.9,-0.1,'\itu')
text(-0.2, 1.65, '\itv')

%insert axis labels
strX = '$$1/2X$$';
text(0.35,-.07,strX,'Interpreter','latex')
strY = '$$\frac{1}{2Y}$$';
text(0.021,.63,strY,'Interpreter','latex');

set(gcf,'Color',[1 1 1]);