Least-squares fitting of cubic Bézier segments to a point sequence. Used by Potrace and Inkscape to convert traced outlines into smooth curves.
After simplification leaves a sparse polyline, curve fitting replaces straight segments with cubic Bézier curves — each defined by four control points: two endpoints and two interior handles. The goal is to find handles that minimise the sum of squared distances between the curve and the original points.
The standard approach is the Schneider algorithm (as described in Graphics Gems): parameterise the input points along the chord, solve for the two handle positions via a 2×2 linear system, then check the maximum error. If error exceeds a threshold, split at the worst point and recurse.
C¹ continuity at segment joins — the curve looks smooth where segments meet.
A cubic Bézier is defined by four control points. Drag any point to see how the curve and its parameterisation change. The small tick marks show equal parameter steps — bunching means the curve slows down there.
Drag any control point. Dashed lines connect endpoints to their handles.
Draw a freehand path or use the generated one below. The fitter finds the minimum number of Bézier segments needed to stay within the error threshold.
Draw on the canvas, or press Reset to use the sample path.
Watch the algorithm try a single segment, measure the error, then split and recurse. The amber point is the current worst-error candidate for splitting.