% a wall of tiles, specified in terms of dilation=a, translation=b, chirp=c
%
% returns a gridwork
%
% USE:  contour(tilesabc(4,4,100,100,1,0,0))
%               tiles(u,v, M , N , dilation_and_zoom, translation, chirp_rate)
%               tiles(u,v, M , N ,a,b,c);
%
%       translation=1 moves image -one pixel down (1 pixel up)
%       translation=i moves image -one pixel right (1 pixel left)
%       dilation_and_zoom = exp(i*30*o) causes 30deg rot CLOCKWISE
%       dilation_and_zoom = 2     makes everything smaller; (more cycles appear)
%
%       group is ax+b not (x-b)/a
%
%       X down, Y right; that makes ROTATION (origin) ABOUT UPPER LEFT CORNER
%
% chirp_rate not yet implemented (take it from tiles.m: angle,f1,f2, and all...)


%function E = dummy(u,v,M,N,angle,f1,f2,X0,Y0);
%function E = dummy(u,v,M,N,dilation_and_zoom,translation,chirp_parameters);
function E = dummy(u,v,M,N,a,b,c);

if nargin >= 7
  disp('chirp parameters not yet implemented; modify tilesabc.m or use tiles.m')
end%if

if nargin<=6
  c = 0;              % identity chirp-rates
end%if
if nargin<=5
  b = 0;              % identity translation
end%if
if nargin<=4
  a = 1 + 0*i;        % identity zoom
end%if

if nargin < 4
  disp('need at least 4 input arguments (e.g. the frequencies and size)')
end%if

%x = cos(2*pi*u*((0:(N-1))/N));
%y = cos(2*pi*v*((0:(M-1))/M));

% generate X and Y on interval [0,1)
[Y, X] = meshgrid((0:(N-1))/N,(0:(M-1))/M);  % this is for X down, Y right

Z = X*M + i*Y*N; % mapping must be performed on a pixel basis to be shearless
Z2 = a*Z + b; % or could use (Z-b)/a for shift to right...
X2 = real(Z2)/M; % put it back on the interval corresponding to [0,1)
Y2 = imag(Z2)/N;

E = cos(2*pi*u*X2).*cos(2*pi*v*Y2);             % chessboard-like pattern
%E = abs(cos(2*pi*u*X2)).*abs(cos(2*pi*v*Y2));   % tile-like pattern

%keyboard

