Skip to main content

fit_curve_sampled

Function fit_curve_sampled 

Source
pub fn fit_curve_sampled(
    point: impl FnMut(f64) -> OgeomResult<Point>,
    ts: &[f64],
    closed: bool,
    degree: usize,
    tolerance: f64,
    tol: Tolerances,
) -> OgeomResult<Fitted<BSplineCurve>>
Expand description

Fit a curve to the geometry point traces over its parameter, measured between the samples as well as at them: the curve counterpart of fit_surface_sampled.

The fit is same-parameter with point, fitted at ts to start with: the least-squares fit first, and where it misses, the spline through every sample. Every span’s eighth points are compared with point there, and the widest misses climbed to the tops of their peaks between them; a miss splits the span at its middle, and this repeats until tolerance holds at every point measured or the samples would pass SAMPLED_SPANS spans. A fit the eighth points pass is read again at eight points of every knot span of its own, its peaks climbed, before it is stated met: a peak at a corner of the trace can stand between the eighth points. Where closed, the last of ts is the first again, the fit crosses its join C1 and refines to at most SAMPLED_LOOP_SPANS spans. The best fit is returned either way, its error the worst distance measured.

§Errors

OgeomError::Construction if the tolerance is not a distance, the degree is zero or the parameters do not strictly increase with at least two; whatever point refuses.