Skip to main content

Module fit

Module fit 

Source
Expand description

Fitting a B-spline to points.

Two jobs that look alike and are not. interpolate makes a curve that passes through every point exactly. approximate makes one that passes near them, with fewer control points than there are points to fit.

§Which one you want

Interpolation is right when the points are exact: corners of a profile, a path a machine must visit. It is wrong for measured data, because it fits the noise as faithfully as the signal, and the wiggles it invents between samples can be large.

Approximation is right when the points are samples of something smoother than they are. It also cannot be told to use as many control points as there are data points; at that ratio the least-squares system is the interpolation system, and calling one function and getting the other is a trap. That case is refused with a message pointing at interpolate.

§Parameterization

Centripetal by default: parameter spacing goes as the square root of the chord, not the chord. Uniform spacing produces visible loops when the points are unevenly spread, and plain chord length overshoots on sharp turns. Centripetal is the standard compromise and is what a CAD user expects a fitted curve to look like.

§Choosing for you

approximate_within is the one that decides: it takes an error target instead of a control-point count, refines its knots where the error concentrates until the target is met, and reports the error it actually reached. The machinery lives in ogeom_geom::fit, where the intersector’s approximation stage shares it.

§Primitives

The other half of fitting measured points: the plane, the sphere, the cylinder, the cone, the torus, the circle or the line that comes nearest them, with every point’s residual (plane, sphere, cylinder, cone, torus, circle3, line3, circle2, line2).

§Zones

Form as a tolerance limits it is not the least-squares fit’s peak to peak but the narrowest zone holding every point: zone fits the minimum zone of a plane, a line, a circle, a cylinder or a sphere, and the largest inscribed and smallest circumscribed circles and cylinders.

§Regions

On a mesh, which points belong to the surface is itself the question: grow takes clicks on a surface, grows the region of the mesh a kind of surface covers around them, and fits it. For a circle or a line it traces the crease nearest the click instead, along edges where the surface turns sharply: a bore’s rim, a box’s edge.

Modules§

zone
Form as the standards define it: minimum-zone, maximum-inscribed and minimum-circumscribed fits.

Structs§

Fit
A fitted shape and how well it fits.
FitFixed
What a fit holds fixed instead of fitting.
FitOptions
How to fit.
GrowOptions
How to grow a region.
Grown
A region grown over a mesh, or a crease traced along it, and its fit.
Meeting
The two planes a Crease::Meeting line is where they meet.
SeedReport
How a seed stands against the region’s fit.

Enums§

AnyFit
A grown region’s or a traced crease’s fit, of the kind asked for.
Crease
How a FitKind::Line3 or a FitKind::Circle3 found its crease.
FitKind
The surface kinds a region is grown for, and the curve kinds a crease is traced for.
Side
Which side of a closed surface or curve the material lies on.
Spacing
How to spread parameters over the points.

Functions§

approximate
Fit a B-spline that passes near the points, with control_count control points.
approximate_within
Fit a B-spline to within a stated error, choosing the knots itself.
circle2
The circle through points in the plane.
circle3
The circle through points in space: the distance a residual measures is to the circle itself, out of its plane as well as across it, and is signed by which side of the cylinder through the circle the point lies.
cone
The cone through points.
cylinder
The cylinder through points.
grow
Grow the region of mesh a surface of kind covers around seeds, and fit it.
interpolate
Fit a B-spline that passes through every point.
line2
The line through points in the plane.
line3
The line through points in space.
plane
The plane through points in space.
sphere
The sphere through points.
torus
The torus through points.