Skip to main content

Module fit

Module fit 

Source
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 tolerance is met.
fit_points_2d
Fit a spline through 2D points, refining until tolerance is 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 t values 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 of fit_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 the v direction 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.