   function [t,OrbPt] = PtOnOrb(z0,P,A,phi)
%
%  Pre: z0 is a column 2-vector and (P,A,phi) defines an orbit.
%
% Post: OrbPt is on the orbit and is associated with time t, and
%       is approximately the closest point on the orbit to z0.

    
    n=60;
	
	% Compute n points around the orbit
	
    tvals = linspace(0,2*pi,n);
	z = Orbit(tvals,A,P,phi);
	
	% Determine the one that is closest to z0
	
	d = zeros(1,n);
	for k=1:n
	   d(k) = norm(z(:,k)-z0);
	end
	[dmin,i] = min(d);
	
	t = tvals(i);
	OrbPt = z(:,i);
	 
