function [points] = Lattice_Points_2d (V,UL,LR) %Lattice_Points_2d: Determine the x and y coordinates of all the points of %the lattice with sampling matrix V within the rectangular region with %upper left coordinates UL and lower right coordinates LR % V - 2x2 nonsingular sampling matrix % UL - [xUL, yUL] x and y coordinate of upper left corner of rectangular % region % LR - [xLR, yLR] x and y coordinates of lower right corner of rectangular % region. % the y axis is oriented downward % Determine the other two corners of the rectangular region UR = [LR(1) UL(2)]'; LL = [UL(1) LR(2)]'; %Coordinates of UL and LR with respect to lattice basis ULV = round(V\UL); LRV = round(V\LR); URV = round(V\UR); ULL = round(V\LL); %Find the minimum and maximum basis coordinates at the four corners of the %rectangle, and expand by one to account for the rounding Llim1 = min([ULV(1) LRV(1) URV(1) ULL(1)])-1; Ulim1 = max([ULV(1) LRV(1) URV(1) ULL(1)])+1; Llim2 = min([ULV(2) LRV(2) URV(2) ULL(2)])-1; Ulim2 = max([ULV(2) LRV(2) URV(2) ULL(2)])+1; ind = 1; %Loop through the points and keep those in the desired region for n1 = Llim1:Ulim1 for n2 = Llim2:Ulim2 x = V*[n1 n2]'; if (x(1) >= UL(1)) & (x(1) <= LR(1)) & (x(2) >= UL(2)) & (x(2) <= LR(2)) points(ind,:) = [x(1) x(2)]; ind = ind+1; end end end