function loc = closest_pt_to_origin(x0,y0,x1,y1)
%
% returns the point on the line [x0,y0,x1,y1] which is closest to the origin
t = (x0*(x0-x1) + y0*(y0-y1))/((x1-x0)^2 + (y1-y0)^2);
x = x0 + (x1-x0)*t;
y = y0 + (y1-y0)*t;
loc = [x,y];
