How can I get a cubic bezier curve closest to given points?

后端 未结 5 491
慢半拍i
慢半拍i 2020-12-30 05:00

Given n points:

p0, p1, p2, ..., pn;

How can I get the point c1, c2 so that the cubic bezier curve defined by

p0, c1, c2, pn

closest to the g

5条回答
  •  盖世英雄少女心
    2020-12-30 05:09

    You might want to have a look at this page : http://www.antigrain.com/research/bezier_interpolation/index.html

    It's a very good implementation, though as the author writes : "This method is pure heuristic and empiric. It probably gives a wrong result from the point of view of strict mathematical modeling. But in practice the result is good enough and it requires absolute minimum of calculations. "

    It's in C++ but is really easily portable to any language... Pass each of your "edges" through the control points calculation function, then through the bezier calculation one, and you have it. To perform bezier smooth on a polygon, pass a last edge with your last and first point.

    Bezier smooth

提交回复
热议问题