function d=distance(v,p)
% Find distances between each point in vector v to the point p.
% Each point should be stored row by row in v.
% Returns a column vector same length as v, containing distance of each point in v from p.
% LR adapted from Stephen Impey(April 1996)

% make p list into same length as v
pn=(p'*ones(1,size(v,1)))';

% get xy difference squared
delta=(pn-v).^2;

% get sum and sqrt
d=sqrt(sum(delta,2));
