Search code examples
matlabcurve-fittingcurve

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.


Solution

  • 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.