Expand description
Fitting a B-spline to points, to a stated error target.
Interpolation and fixed-count approximation live in ogeom-algo, and both
take a control-point count from the caller. This module chooses it: fit,
measure where the fit is worst, refine the knots exactly there, and repeat
until the error target is met.
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.
§What the error measures
A fit through bare points (fit_points, fit_points_at,
fit_surface_grid, fit_surface_scattered and their siblings) has
nothing to measure against but the points, and its error is the distance
at the points only. Between them the fit runs as close to the sampled
shape as a smooth spline through those samples does, which for smooth
data shrinks with the sample spacing, but no number here bounds it. A
caller holding the true geometry measures there, or fits with
fit_curve_sampled or fit_surface_sampled, whose error covers the
points between the samples too and is no less than the widest miss.
§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.
- Sampling
- Where
fit_surface_sampledstarts sampling and how far it may refine. - Scattered
Fit - What
fit_surface_scattered_overproduced. - Scattered
Options - What
fit_surface_scattered_overfits with.
Enums§
- Ended
- Why
fit_surface_scattered_overstopped. - Target
- How far
fit_surface_scattered_overrefines its control net.
Constants§
- SAMPLED_
LOOP_ SPANS - The most spans a closed sampled fit refines its samples to. A loop’s join couples its first and last control points, so its least-squares system is solved whole rather than as a band, at a cost that grows with the cube of the samples.
- SAMPLED_
SPANS - The most spans an open sampled fit refines its samples to
(
fit_curve_sampled,fit_curve_2d_sampled).
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_
curve_ 2d_ sampled - As
fit_curve_sampled, in the plane: a chart image fitted at the parameters of the curve it annotates. The distances are in the trace’s own units. - fit_
curve_ sampled - Fit a curve to the geometry
pointtraces over its parameter, measured between the samples as well as at them: the curve counterpart offit_surface_sampled. - 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. The error is measured at the given points only;fit_curve_sampledmeasures between them too. - fit_
points_ at_ closed - As
fit_points_at, with the loop’s join made C1: the points close, the last the first again. - 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_
points_ joint_ from - As
fit_points_joint, at chord-length parameters held fixed, its knots starting at the parameters of the samplesstationsnames. - fit_
points_ joint_ from_ held - As
fit_points_joint_from, splitting a span only where samples lie strictly inside it on both sides of the new knot. - fit_
points_ joint_ winding - As
fit_points_joint_closed, for a loop closed in space whose pcurves may end a whole period from where they began: a section winding once round a periodic surface. The join is C1 in every coordinate, which is right where the chart runs at one speed across its seam, as a periodic surface’s does. A patch that merely meets itself need not. - fit_
surface_ grid - Fit a rectangular grid of points with a tensor-product B-spline surface.
- fit_
surface_ grid_ at - Fit a rectangular grid at fixed parameters:
u_params[i]is the surface’s ownuatrows[j][i], andv_params[j]itsv. - fit_
surface_ grid_ at_ with_ knots - As
fit_surface_grid_at, each direction’s knots starting from the interior knots given for it,(parameter, multiplicity), and keeping them. Where the chart the points come from is only C0 or C1 along a parameter line, a knot there of multiplicitydegreeordegree - 1lets the fit turn as the chart does; without one, a fit smoother than its data converges on such a line only as fast as its spans shrink. A multiplicity past the degree counts as the degree, and a knot outside the parameters’ open range is not used. - 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_ grid_ sections - As
fit_surface_grid, with the rows placed acrossvby chord length: sections lofted through, where the spacing between sections is the skin’s own and may change along it. Centripetal parameters squash a change of spacing (a step twice another’s gets a parameter step only about one and a half times as long), and a cubic through sections so placed sags between them. Each row keeps the centripetal assignment alongu. - fit_
surface_ sampled - Fit a surface to the geometry
pointtraces over its parameters, measured between the samples as well as at them. - fit_
surface_ scattered - Fit a surface to scattered points: no grid required.
- fit_
surface_ scattered_ at - Fit a surface to scattered points at parameters the caller chose, over the caller’s knot vectors, faired by the thin-plate energy.
- fit_
surface_ scattered_ over - Fit a surface to scattered points, parameterised over a seed surface.
- fit_
trace_ sampled - Fit a curve on a surface and its chart image together to the trace
tracegives over its parameter: at each parameter the point in space and its chart position,on_surfacethe surface the chart belongs to. - grid_
parameters - The parameters
fit_surface_gridand its chord-length and section variants assign a rectangular grid: one shared assignment per direction, the average of every row’s (u) and every column’s (v), chord length or centripetal asby_chordsays per direction.