function [rpts, ind] = order_xy_pts(pts)
% function [rpts] = order_xy_pts(pts)
%
% Dr. A. I. Hanna (2006).
if size(pts,1)>1
    mpts = mean(pts,1);
else
    mpts = pts;
end
rpts = double(pts) - ones(size(pts,1),1)*mpts;
[theta, r] = cart2pol(rpts(:,1), rpts(:,2));
polvec = [theta, r];
[polvec, ind] = sortrows(polvec,1);
[rpts(:,1), rpts(:,2)] = pol2cart(polvec(:,1), polvec(:,2));
rpts = rpts + ones(size(rpts,1),1)*mpts;
return;