function f=wavesavi(aviname)
% wave field movie

if nargin==0, aviname='waves.avi'; end;
for i=1:24,
    [x,y,z]=waves(15*i);
    h=surf(z);
    shading flat;
    axis equal;
    axis off;
    view(10,35);
    set (h,'FaceColor',0.6*[1 1 1]);
    lightangle(130,50);
    lighting gouraud;
    f(i)=getframe;
end;
if nargout==0, 
    movie2avi(f, aviname, 'quality',95);
end;

function [x,y,z]=waves(phi)
% wave field 

if (nargin<1), phi=0; end;
f=3;
a=phi*pi/180;
Size=100*f;
k=2*pi/9/f;
[x,y]=meshgrid(0:Size);
dy=Size/10;
y1=Size/2+dy;
y2=Size/2-dy;
r1=sqrt(x.*x+(y-y1).*(y-y1));
r2=sqrt(x.*x+(y-y2).*(y-y2));
z=2*f*(sin(k*r1-a)+sin(k*r2-a));
