I'm devising an algorithm to take a freehand curve and make a bezier spline from it. I can do this already just fine, but it's a naive implementation that creates about as many bezier curves as there are unique stylus inputs, which is a large amount. It works, but it would be better if I could reduce the curve only to an essential number of bezier segments necessary to approximate the freehand drawing. I've studied the results in other vector drawing programs and they will typically have many points around areas of high curvature and then few in straight parts of the curve. My question is how to best accomplish this. The best idea I have right now is to simply compare a freehand point with the two prior freehand points and if it does not deviate from some angle threshold on the line created by those two points, do not make a new segment from it. This sort of approximates what the curvature would be. But I am wondering if there is a more established algorithm for this?

  • 1
    $\begingroup$ You probably want to look into line simplification algorithms. One of the most well-known ones is the Ramer-Douglas-Peucker algorithm. See also the "Similar algorithms" section for other approaches. $\endgroup$
    – waldyrious
    Jul 25 at 21:20
  • $\begingroup$ @waldyrious that's a neat algorithm, thanks! $\endgroup$
    – johnbakers
    Jul 26 at 19:31


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.