tenos
tenos

Reputation: 959

How to fitting a curve with a point set like in the figure below

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.

Figure:
fig http://www.baidupcs.com/thumbnail/fbdd467ca3dce4e05e55b209bf6cc6dd?fid=3154234395-250528-2669431106&time=1364974850&sign=FDTA-DCb740ccc5511e5e8fedcff06b081203-2skix2HZJ0DXlkEgRMUWxxsBeQQ%3D&expires=8h&size=c850_u580&quality=100

Edit: Both Floris and pancake gave a correct answer,thank you for both.

Upvotes: 1

Views: 404

Answers (2)

Floris
Floris

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

pancake
pancake

Reputation: 3450

Rather than fitting 'y' as a function of 'x', you need to fit separately:

  • 'x' as a function of 't'
  • 'y' as a function of 't'

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

Related Questions