fit_cubic_bspline_control_points
Kind: Function
Domain: Other public symbols
Canonical import: from cadflow import fit_cubic_bspline_control_points
Signature
def fit_cubic_bspline_control_points(sample_points: 'Sequence[Sequence[float]]', *, tolerance: 'float' = 0.001, max_control_points: 'Optional[int]' = None, fairing: 'float' = 1e-06, duplicate_tolerance: 'float' = 1e-12, knot_tolerance: 'float' = 1e-09, raise_on_failure: 'bool' = True) -> 'BSplineFitResult'
Description
Fit a minimal cubic B-spline control polygon to sampled curve points.
Fit a minimal cubic B-spline control polygon to sampled curve points.
Uses chord-length parameterization, cubic clamped B-spline least squares, second-difference fairing regularization, and adaptive simple knot insertion until the maximum sample error is within tolerance. Only simple interior knots are inserted, so a cubic result remains C2-continuous at every interior knot.
Parameters
| Name | Type | Required | Default | Source description |
|---|---|---|---|---|
sample_points | 'Sequence[Sequence[float]]' | yes | - | Ordered 2D or 3D points sampled along the intended curve. Consecutive duplicate points within duplicate_tolerance are ignored. |
tolerance | 'float' | no | 0.001 | Maximum allowed Euclidean fitting error at the input samples. |
max_control_points | 'Optional[int]' | no | None | Upper bound for fitted control points. Defaults to the cleaned sample count, with a cubic minimum of four controls. |
fairing | 'float' | no | 1e-06 | Non-negative second-difference regularization weight. Larger values prefer smoother control polygons while still respecting the error tolerance when possible. |
duplicate_tolerance | 'float' | no | 1e-12 | Distance threshold for removing consecutive duplicate sample points before chord-length parameterization. |
knot_tolerance | 'float' | no | 1e-09 | Normalized parameter spacing threshold used to avoid duplicate or near-boundary interior knots. |
raise_on_failure | 'bool' | no | True | Raise ValueError when the tolerance cannot be reached within max_control_points. If false, return the best non-converged result instead. |
Returns
Type: 'BSplineFitResult'
BSplineFitResult containing cubic degree, control points, a full clamped knot vector, knot multiplicities, sample parameters, and fitting error.
Errors
ValueError: If inputs are invalid, or if the tolerance cannot be met andraise_on_failure=True.
Behavior and constraints
- The contract below is generated from the current public runtime signature. Check domain notes for ownership and workflow constraints.
Import check
from cadflow import fit_cubic_bspline_control_points