
% spheregridmovie.m
% Produces a movie illustrating figure 1(a) of 
%  Wave Propagation Software, Computational Science, and Reproducible Research
%  by R. J. LeVeque, http://www.amath.washington.edu/~rjl/pubs/icm06

n = 30;
[xc,yc] = meshgrid(linspace(-1,1,n+1),linspace(-1,1,n+1));
[xp1,yp1]=mapc2p(xc,yc);

xp0 = xc;
yp0 = yc;

nframes = 11;   % number of frames in the movie
for Frame=1:nframes
  % for this frame, interpolate between rectangle and circle:
  alf = (Frame-1)/(nframes-1);
  xp = (1-alf)*xp0 + alf*xp1;
  yp = (1-alf)*yp0 + alf*yp1;

  clf
  surf(xp,yp,zeros(size(xp)))

  colormap([1 1 1])
  axis([-1 1 -1 1])
  daspect([1 1 1])
  axis off
  % makeframejpg % make jpg file for this frame (uses claw/matlab/ m-files)
  pause
  end

% If a jpg file was made for each frame, execute    
%      convert -resize 600x600 frame*.jpg circlemovie.gif
% or 
%      convert -delay 10 -adjoin frame*.jpg circlemovie.mpeg
% or similar command in unix to create the movie
