pub struct KnotVector { /* private fields */ }Expand description
A non-decreasing knot sequence with an associated degree.
Implementations§
Source§impl KnotVector
impl KnotVector
Sourcepub fn new(knots: Vec<f64>, degree: usize) -> OgeomResult<Self>
pub fn new(knots: Vec<f64>, degree: usize) -> OgeomResult<Self>
A knot vector from a flat non-decreasing sequence.
§Errors
OgeomError::Construction if the
sequence is too short for the degree, is not non-decreasing, contains a
non-finite value, or has an interior knot of multiplicity greater than
the degree, which would disconnect the curve rather than merely make it
sharp.
Sourcepub fn clamped_uniform(
degree: usize,
control_points: usize,
) -> OgeomResult<Self>
pub fn clamped_uniform( degree: usize, control_points: usize, ) -> OgeomResult<Self>
A clamped uniform knot vector for control_points control points.
The domain is [0, 1], the ends are clamped, and the interior knots are
evenly spaced.
§Errors
OgeomError::Construction if there are
too few control points for the degree.
Sourcepub fn averaged(degree: usize, parameters: &[f64]) -> OgeomResult<Self>
pub fn averaged(degree: usize, parameters: &[f64]) -> OgeomResult<Self>
A clamped knot vector from parameter values, for interpolation.
Uses the averaging rule, which places interior knots so that the resulting interpolation system is well conditioned; a uniform vector over unevenly spaced parameters gives a nearly singular one.
§Errors
OgeomError::Construction if there are
too few parameters, or they are not strictly increasing.
Sourcepub const fn control_point_count(&self) -> usize
pub const fn control_point_count(&self) -> usize
The number of control points this vector describes.
Sourcepub fn domain_start(&self) -> f64
pub fn domain_start(&self) -> f64
The first parameter of the usable domain.
Sourcepub fn domain_end(&self) -> f64
pub fn domain_end(&self) -> f64
The last parameter of the usable domain.
Sourcepub fn is_clamped(&self) -> bool
pub fn is_clamped(&self) -> bool
Whether the ends are clamped, so the curve meets its first and last control points.
Sourcepub fn multiplicity_at(&self, index: usize) -> usize
pub fn multiplicity_at(&self, index: usize) -> usize
The multiplicity of the knot value at index.
Exact: repeated knots are bit-identical by construction.
Sourcepub fn multiplicity_of(&self, value: f64) -> usize
pub fn multiplicity_of(&self, value: f64) -> usize
The multiplicity of value, or zero if it is not a knot.
Sourcepub fn distinct(&self) -> Vec<(f64, usize)>
pub fn distinct(&self) -> Vec<(f64, usize)>
The distinct knot values with their multiplicities, in order.
Sourcepub fn contains(&self, u: f64, tol: Tolerances) -> bool
pub fn contains(&self, u: f64, tol: Tolerances) -> bool
Whether u lies in the usable domain, within tol.parametric().
Sourcepub fn span(&self, u: f64, tol: Tolerances) -> OgeomResult<usize>
pub fn span(&self, u: f64, tol: Tolerances) -> OgeomResult<usize>
The index of the knot span containing u.
Returns i with knots[i] <= u < knots[i+1], clamped so that the end of
the domain resolves to the last non-empty span rather than falling off
it. Binary search, so cost is logarithmic in the knot count.
§Errors
OgeomError::Domain if u is outside the
domain by more than tol.parametric().
Sourcepub fn span_unchecked(&self, u: f64) -> usize
pub fn span_unchecked(&self, u: f64) -> usize
The knot span containing u, clamping out-of-range values into the
domain rather than reporting them.
Sourcepub fn basis(&self, span: usize, u: f64) -> BasisValues
pub fn basis(&self, span: usize, u: f64) -> BasisValues
The degree + 1 non-zero basis functions at u.
Entry i is the value of basis function span - degree + i. They are
non-negative and sum to exactly one up to rounding: the partition of
unity, which is what makes a B-spline curve lie in the convex hull of its
control points.
Cox-de Boor, in the triangular form that avoids evaluating the zero functions and never divides by a zero knot difference.
Sourcepub fn basis_derivatives(&self, span: usize, u: f64, n: usize) -> DerivativeRows
pub fn basis_derivatives(&self, span: usize, u: f64, n: usize) -> DerivativeRows
The non-zero basis functions and their derivatives up to order n.
result[k][i] is the kth derivative of basis function
span - degree + i. Orders above the degree are identically zero and
are returned as such rather than as noise.
Sourcepub fn with_knot_inserted(&self, value: f64, count: usize) -> OgeomResult<Self>
pub fn with_knot_inserted(&self, value: f64, count: usize) -> OgeomResult<Self>
Insert value into the sequence, count times.
Only the knots change; adjusting control points to keep the shape is
crate::bspline::insert_knot.
§Errors
OgeomError::Construction if the result
would push a knot’s multiplicity above the degree.
Sourcepub fn reparameterized(&self, start: f64, end: f64) -> OgeomResult<Self>
pub fn reparameterized(&self, start: f64, end: f64) -> OgeomResult<Self>
This vector with its domain mapped onto [start, end].
§Errors
OgeomError::Construction if the target
range is empty or non-finite.
Sourcepub fn reversed(&self) -> Self
pub fn reversed(&self) -> Self
This vector with the parameter direction reversed.
The domain is preserved and the sequence of interior spacings is mirrored. Reversing a curve reverses its knots and its control points together.
Multiplicity is preserved exactly (equal knots map through the same
arithmetic and so stay equal), which is what continuity depends on. The
interior knot values are not bit-exactly restored by reversing twice,
since a + b - k is not an exact involution in floating point; they
return to within one ulp.
Trait Implementations§
Source§impl Clone for KnotVector
impl Clone for KnotVector
Source§fn clone(&self) -> KnotVector
fn clone(&self) -> KnotVector
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KnotVector
impl Debug for KnotVector
Source§impl PartialEq for KnotVector
impl PartialEq for KnotVector
Source§fn eq(&self, other: &KnotVector) -> bool
fn eq(&self, other: &KnotVector) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for KnotVector
Auto Trait Implementations§
impl Freeze for KnotVector
impl RefUnwindSafe for KnotVector
impl Send for KnotVector
impl Sync for KnotVector
impl Unpin for KnotVector
impl UnsafeUnpin for KnotVector
impl UnwindSafe for KnotVector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.