% Parametric form of the distance function u(x,y) to y=x^2
%
%  x=xo +/- 2 xo u/sqrt(4 xo^2+1)
%  y=xo^2 -/+ u/sqrt(4 xo^2+1)
%
%  Save this file in your directory as "whatever.m" 
%  start matlab, type "whatever".
%
% Fabian Waleffe, Math 704, 04/05/2002

figure(1),clf, clear M

N=300; xo=3.3*[-1:1/N:1];

% locus of ray intersections = evolute of the parabola

x1=-4*xo.^3; y1= (1+6*xo.^2)/2; 

for j=1:40

  u=j*0.1;

  fac= u./sqrt(4*xo.^2+1);
  xp=xo+ 2*xo.*fac; xm=xo - 2*xo.*fac; yp=xo.^2-fac; ym=xo.^2+fac;

  plot(xo,xo.^2,xp,yp,xm,ym,x1,y1)
  axis image,  axis([-8 8  -4 10]),
  M(j) = getframe;

end

movie(M,5)
