Module fit

Source
Expand description

An implementation of cubic Bézier curve fitting based on a quartic solver making signed area and moment match the source curve.

Structs§

CurveDist 🔒
An acceleration structure for estimating curve distance
CurveFitSample
A sample point of a curve for fitting.

Enums§

FitResult 🔒

Constants§

D_PENALTY_ELBOW 🔒
As described in Simplifying Bézier paths, strictly optimizing for Fréchet distance can create bumps. The problem is curves with long control arms (distance from the control point to the corresponding endpoint). We mitigate that by applying a penalty as a multiplier to the measured error (approximate Fréchet distance). This is ReLU-like, with a value of 1.0 below the elbow, and a given slope above it. The values here have been determined empirically to give good results.
D_PENALTY_SLOPE 🔒
N_SAMPLE 🔒

Traits§

ParamCurveFit
The source curve for curve fitting.

Functions§

cubic_fit 🔒
Returns curves matching area and moment, given unit chord.
fit_opt_err_delta 🔒
fit_opt_segment 🔒
fit_to_bezpath
Generate a Bézier path that fits the source curve.
fit_to_bezpath_opt
Generate a highly optimized Bézier path that fits the source curve.
fit_to_bezpath_opt_inner 🔒
Fit a range without cusps.
fit_to_bezpath_rec 🔒
fit_to_cubic
Fit a single cubic to a range of the source curve.
measure_one_seg 🔒
try_fit_line 🔒
Try fitting a line.