Fitting a closed curve to a set of points

后端 未结 4 2040
清歌不尽
清歌不尽 2020-11-27 04:04

I have a set of points pts which form a loop and it looks like this:

\"enter

4条回答
  •  情书的邮戳
    2020-11-27 04:50

    To fit a smooth closed curve through N points you can use line segments with the following constraints:

    • Each line segment has to touch its two end points (2 conditions per line segment)
    • For each point the left and right line segment have to have the same derivative (2 conditions per point == 2 conditions per line segment)

    To be able to have enough freedom for in total 4 conditions per line segment the equation of each line segment should be y = ax^3 + bx^2 + cx + d. (so the derivative is y' = 3ax^2 + 2bx + c)

    Setting the conditions as suggested would give you N * 4 linear equations for N * 4 unknowns (a1..aN, b1..bN, c1..cN, d1..dN) solvable by matrix inversion (numpy).

    If the points are on the same vertical line special (but simple) handling is required since the derivative will be "infinite".

提交回复
热议问题