Reputation: 5497
I have to write a function that converts cubic bezier (start, end, cp1, cp2) to simple quadratic (start, end, cp1) instances (one cubic can turn to 2 or more quadratic).
Any coding language is accepted, I just need the algorithm.
Upvotes: 1
Views: 3073
Reputation: 162164
There are certain shapes, like circles, which can be approximated good enough by cubic but not by quadratic bezier. So from a purely mathematical point of view, the task can not be solved.
It is however possible, of course, to approximate a single cubic bezier with a set of piecewise quadratic beziers. The enpoints of each quadratic would lie on the exact points of the cubic. The control points you'd find by some means of optimization (least squares, or something similar) where you try to minimize the difference between the cubic and the quadratic bezier.
Upvotes: 4
Reputation: 5497
finally I've decided to implement it by my own, with a lineto loop, similar to this: http://www.paultondeur.com/2008/03/09/drawing-a-cubic-bezier-curve-using-actionscript-3/
Upvotes: 0