% P4 Checks minDist
  clc
  randn('seed',0)
  disp('   u       v         distance             tStar')
  disp('----------------------------------------------------')
  close all
  a = 5; b = 2; tol = 10^-8;
  plot(a*cos(linspace(0,2*pi)), b*sin(linspace(0,2*pi)))
  axis equal off
  hold on

  for z=[ 3 -3  -3  3 0 3*randn(1,5);4 4 -4 -4 0 3*randn(1,5)]
     u = z(1); v = z(2);
     [d,tStar] = minDist(u,v,a,b,tol);
     xE = a*cos(2*pi*tStar); yE = b*sin(2*pi*tStar);
     plot([u xE],[v yE],'*r',[u xE],[v yE],'r')
     fprintf('%7.3f %7.3f  %15.9f    %15.9f\n',u,v,d,tStar)
  end


