%Chapter 5, Example 5.3: Fig 5.3 (b) %Eric Dubois, updated 2018-11-16 %Create test pattern of example 5.3 as an line drawing %Required functions: Lattice_Points_2d, ds2nfu by Michelle Hirsch clear all close all %Sampling matrix and extent for periodicity lattice VG = [4 2;0 1.5]; UL = [-5 -6]'; LR = [5 5]'; %get the points of the lattice in the desired region xoutG = Lattice_Points_2d(VG,UL,LR); %create the plot figure %Plot the lattice points points = plot(xoutG(:,1),xoutG(:,2),'k.'); points(1).MarkerSize= 9; axis equal axis off set(gca,'ydir','reverse'); %set region xlim([-5, 5]); ylim([-5, 5]); hold on %Plot the diamonds on the points of Gamma diam = polyshape([1 0 -1 0],[0 1 0 -1]); nptGamma = size(xoutG,1); for rpt = 1:nptGamma diamT = translate(diam,xoutG(rpt,:)); plot(diamT,'Facecolor','white','FaceAlpha',0,'EdgeColor','black'); end %Plot the squares on the points of Gamma square = polyshape([.25 -.25 -.25 .25],[.25 .25 -.25 -.25]); for rpt = 1:nptGamma squareT = translate(square,xoutG(rpt,:)); plot(squareT,'Facecolor','white','FaceAlpha',0,'EdgeColor','black'); squareT2 = translate(square,xoutG(rpt,:)+[0 1.5]); plot(squareT2,'Facecolor','white','FaceAlpha',0,'EdgeColor','black'); end %create the axes text(5.6,-0.35,'\itx','FontName','times') text(0.25, 5, '\ity','FontName','times') %x axis from -5 to 5 [xaxx,xaxy] = ds2nfu([-5.3 5.2], [0 0]); annotation('arrow',xaxx,xaxy,'headlength',5,'headwidth',5); %y axis from -5 to 5 [yaxx,yaxy] = ds2nfu([0.0 0.0],[5.2 -5.2]); annotation('arrow',yaxx,yaxy,'headlength',5,'headwidth',5); %Label axes text(1.03,.15,'1','FontName','times'); text(-1.4,.15,'-1','FontName','times'); text(-.5,1,'1','FontName','times'); text(-.6,-1,'-1','FontName','times'); %Ticks plot([1 1],[-.1 .1],'k'); plot([2 2],[-.1 .1],'k'); plot([3 3],[-.1 .1],'k'); plot([4 4],[-.1 .1],'k'); plot([-1 -1],[-.1 .1],'k'); plot([-2 -2],[-.1 .1],'k'); plot([-3 -3],[-.1 .1],'k'); plot([-4 -4],[-.1 .1],'k'); plot([-.1 .1],[1 1],'k'); plot([-.1 .1],[2 2],'k'); plot([-.1 .1],[3 3],'k'); plot([-.1 .1],[4 4],'k'); plot([-.1 .1],[-1 -1],'k'); plot([-.1 .1],[-2 -2],'k'); plot([-.1 .1],[-3 -3],'k'); plot([-.1 .1],[-4 -4],'k'); %Label signal values text(1,-2.4,'0','FontName','times'); text(1.85,-2.1,'1','FontName','times'); text(1.75,-3.,'0.5','FontName','times'); %Draw the Voronoi cell hex = polyshape([1.5 0.5 -0.5 -1.5 -0.5 0.5],[0 1.5 1.5 0 -1.5 -1.5]); plot(hex,'FaceColor','white','FaceAlpha',0,'EdgeColor','red'); set(gcf,'Color',[1 1 1]);