Skip to main content

fit_surface_scattered_over

Function fit_surface_scattered_over 

Source
pub fn fit_surface_scattered_over(
    points: &[Point],
    seed: &SurfaceGeometry,
    options: &ScatteredOptions,
    tol: Tolerances,
) -> OgeomResult<ScatteredFit>
Expand description

Fit a surface to scattered points, parameterised over a seed surface.

Each point takes the parameters of its nearest point on seed: a closed form on a plane, cylinder, cone, sphere or torus (the whole surface, whatever window it carries), the projector’s search on anything else, a previous fit included. A periodic direction is cut at the widest gap the points leave round it, so a band across the seed’s seam stays in one piece; a cloud that runs all the way round is fitted open across that gap. The parameters are then scaled onto the unit square. The seed must unfold the points: a sphere seed’s poles belong away from them, where longitude still tells points apart.

The net is fitted at those parameters by fit_surface_scattered_at, faired as it fairs. Every distance reported is from a point to its nearest point on the fit, found from its parameters.

With Target::Tolerance the spans are then split where the fit misses. A cell (a u span by a v span) misses where one of its points stands farther from the fit than the tolerance and is not a stray, one standing farther than the noise of the rest of its cell (their root mean square distance) reaches over m points, √(2 ln m) times it (Ended::Strays). A cell is split only where it holds at least as many points as the (degree + 1)² controls that bear on it, fewer leaving its controls to the fairing.

Each round splits the worst-missed cell’s u span, its v span, or both, at the middle, keeping the try with the least squared distances plus twice the noise’s variance per control (Mallows’ criterion, the variance estimated from the fit’s median distance), so a shape that turns along one direction only gains spans along that one. A cell beside the worst can miss by the ringing of a fit that has not yet caught it, which a split at the worst takes out. Where no try scores below the fit so far, the split would fit noise rather than shape, and refinement ends there (Ended::Noise), as it does for a tolerance inside the noise’s reach.

§Errors

OgeomError::Construction if there are fewer than eight points, a point is not finite, the degree is nought, a span count is nought or its bound below it, the fairing is not finite and non-negative, the tolerance is not a distance, a point has no nearest point on the seed (on a cylinder’s axis, at a sphere’s centre), or the points’ parameters do not spread over both directions; OgeomError::Numeric if the whole cloud cannot settle the net (raise the fairing).