convert bezier curve to polygonal chain?

dr jerry picture dr jerry · Feb 12, 2012 · Viewed 8.5k times · Source

I want to split a bezier curve into a polygonal chain with n straight lines. The number of lines being dependent on a maximum allowed angle between 2 connecting lines. I'm looking for an algorithm to find the most optimal solution (ie to reduce as much as possible the number of straight lines).

I know how to split a bezier curve using Casteljau or Bernstein polynomals. I tried dividing the bezier into half calculate the angle between the straight lines, and split again if the angle between the connecting lines is within a certain threshold range, but i may run into shortcuts.

Is there a known algorithm or pseudo code available to do this conversion?

Answer

lhf picture lhf · Feb 12, 2012

Use de Casteljau algorithm recursively until the control points are approximately collinear. See for instance http://www.antigrain.com/research/adaptive_bezier/index.html.