Skip to main content

fit_surface_grid

Function fit_surface_grid 

Source
pub fn fit_surface_grid(
    points: &[Vec<DVec3>],
    options: &SurfaceFitOptions,
) -> Result<SurfaceFit, GeomError>
Expand description

Fit a tensor-product B-spline surface to a rectangular grid of points, points[i][j] at row i (the u direction) and column j (the v direction), every row the same length.

The fit is separable (Piegl and Tiller section 9.4): each row is least-squares fit along u sharing one design matrix and one global u knot vector (parameters averaged across rows), producing an intermediate u_control_count x cols net; each column of that net is then least-squares fit along v the same way. The result is not the global two-dimensional optimum a single joint solve would give, but it is deterministic, reuses the already-certified curve fit, and matches how axiolid-nurbs already builds surfaces from curve data (loft_surface).

ยงErrors

Refuses fewer than two rows or columns, ragged rows, non-finite points, an invalid degree, a control count outside degree + 1 ..= point count on either axis, coincident consecutive rows or columns under chord-length or centripetal parameterisation, and a rank-deficient system on either axis.