Skip to main content

fit_trace_sampled

Function fit_trace_sampled 

Source
pub fn fit_trace_sampled(
    trace: impl FnMut(f64) -> OgeomResult<(Point, Point2)>,
    on_surface: impl Fn(Point2) -> OgeomResult<Point>,
    ts: &[f64],
    degree: usize,
    tolerance: f64,
    tol: Tolerances,
) -> OgeomResult<(Fitted<BSplineCurve>, BSpline2d)>
Expand description

Fit a curve on a surface and its chart image together to the trace trace gives over its parameter: at each parameter the point in space and its chart position, on_surface the surface the chart belongs to.

One knot vector and one parameterization for both, fixed at ts to start with, so the two are same-parameter with the trace and with each other. Every sample and every span’s eighth points are measured in space: the curve and the surface at the image’s chart position, each against the trace’s point and against each other, and the widest misses climbed to the tops of their peaks between them, and once those pass, every knot span of the fit at eight points, as fit_curve_sampled reads it. A miss splits the span, and this repeats until tolerance holds at every point measured or the samples would pass 1024 spans; the error is the worst measured either way. The chart coordinates are weighed in the fit by the surface’s own speed along them, so a residual in either space counts as the distance it is.

§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 trace refuses, and whatever on_surface refuses other than a position off the surface’s domain, which a fitted image straying there misses by more than any distance and is refined away from.