Expand description
Fitting a B-spline to points, to a stated error target.
The missing half of fitting. Interpolation and fixed-count approximation
exist in ogeom-algo; what they cannot do is choose: the caller names a
control-point count and hopes. This module is the loop that closes that:
fit, measure where the fit is worst, refine the knots exactly there, and
repeat until the error target is met.
docs/PLAN.md carries this with a warning worth repeating: a fit that
silently picks its own resolution and reports success is the shape of answer
that gets trusted. So the result here carries the error actually reached and
whether the target was met, and a fit that ran out of room says so rather
than rounding “close” up to “done”.
§Where the knots go
Refinement is where the error is, not everywhere. Splitting every span doubles the control points per round and most of them buy nothing; a curve that is straight for most of its length and tight in one corner needs its knots in the corner. Each round measures the error per span and splits only the spans that exceed the target, so the knot density ends up tracking the curvature, which is where it belongs.
§Who this is for
The marching intersector, first: a traced branch is a polyline with a stated chord tolerance, and downstream code wants a curve, so the polyline is fitted to the same tolerance and the result is as good as the trace. But nothing here knows about intersections; it fits points, in three dimensions or two, which is also what a digitized profile or an imported polyline needs.
Structs§
- Fitted
- What a fit produced.
Functions§
- fill_
boundary - Fill the region bounded by four curves with a fitted patch: the transfinite Coons blend of the boundaries, sampled and fitted, its error reported.
- fit_
points - Fit a spline through 3D points, refining until
toleranceis met. - fit_
points_ 2d - Fit a spline through 2D points, refining until
toleranceis met. - fit_
points_ 2d_ at - Fit a pcurve at fixed parameters: the source curve’s own.
- fit_
points_ 2d_ at_ closed - As
fit_points_2d_at, with the loop’s join made C1. - fit_
points_ at - Fit space points at fixed parameters: the caller’s
tvalues are the curve’s own, which is what keeps a replacement curve same-parameter with every chart already speaking the old one. - fit_
points_ closed - Fit a smoothly closed loop: as
fit_points, with the join C1. - fit_
points_ faired - Fit a fair curve: least squares over the points, pulled toward minimum bending energy by a smoothing weight.
- fit_
points_ joint - Fit one curve living in three spaces at once: a 3D curve and its two parameter-space images, as a single seven-dimensional fit.
- fit_
points_ joint_ closed - As
fit_points_joint, with a closed loop’s join made C1. - fit_
surface_ grid - Centripetal parameters over the points, on
[0, 1]. Fit a rectangular grid of points with a tensor-product B-spline surface. - fit_
surface_ grid_ chordal - As
fit_surface_grid, parameterized by chord length instead of the centripetal assignment, the open counterpart offit_surface_grid_closed_v_chordal, for a marched band that stops at its run-out instead of closing on itself. - fit_
surface_ grid_ closed_ v - As
fit_surface_grid, with thevdirection closed into a smooth loop. - fit_
surface_ grid_ closed_ v_ chordal - As
fit_surface_grid_closed_v, parameterized by chord length instead of the centripetal assignment. - fit_
surface_ scattered - Fit a surface to scattered points: no grid required.