Reputation: 959
As the points in the figure, a 'X' may map two "Y" value and a 'Y' may map two "X" value.
When fitting a curve with these points, it should ensure that first-order derivative and
second-order derivative can be calculated.
Edit: Both Floris and pancake gave a correct answer,thank you for both.
Upvotes: 1
Views: 404
Reputation: 46375
Pick a point in the middle of your cluster of points - could be the center of gravity. Draw an imaginary line from this "origin" to the first point. The distance to the point r=sqrt((x-x0)^2+(y-y0)^2);
and the angle theta=atan2((y-y0),(x-x0));
. Compute r
and theta
for all points; if theta wraps, add 2*pi to make it continuous. Now you can spline fit the function r of theta. Finally you can interpolate the spline for many values of theta and compute the corresponding x=r*cos(theta);
and y=r*sin(theta);
That ought to do it.
Upvotes: 1
Reputation: 3450
Rather than fitting 'y' as a function of 'x', you need to fit separately:
where 't' is the intrinsic coordinate of a spline (or other curve fit, eg. polynomial).
I assume in the picture you know the order of the points - it's not just a jumble of unsorted points? So first of all, you could calculate the distance between each successive point, and use the cumulative distance as your 't' parameter. Then fit splines to the 'x' and 'y' coordinates as functions of t.
Upvotes: 1