Skip to main content

KnotVector

Struct KnotVector 

Source
pub struct KnotVector { /* private fields */ }
Expand description

A non-decreasing knot sequence with an associated degree.

Implementations§

Source§

impl KnotVector

Source

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.

Source

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.

Source

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.

Source

pub const fn degree(&self) -> usize

The degree.

Source

pub fn knots(&self) -> &[f64]

The flat knot sequence.

Source

pub const fn control_point_count(&self) -> usize

The number of control points this vector describes.

Source

pub fn domain_start(&self) -> f64

The first parameter of the usable domain.

Source

pub fn domain_end(&self) -> f64

The last parameter of the usable domain.

Source

pub fn domain(&self) -> (f64, f64)

The usable domain.

Source

pub fn is_clamped(&self) -> bool

Whether the ends are clamped, so the curve meets its first and last control points.

Source

pub fn multiplicity_at(&self, index: usize) -> usize

The multiplicity of the knot value at index.

Exact: repeated knots are bit-identical by construction.

Source

pub fn multiplicity_of(&self, value: f64) -> usize

The multiplicity of value, or zero if it is not a knot.

Source

pub fn distinct(&self) -> Vec<(f64, usize)>

The distinct knot values with their multiplicities, in order.

Source

pub fn contains(&self, u: f64, tol: Tolerances) -> bool

Whether u lies in the usable domain, within tol.parametric().

Source

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().

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> KnotVector

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KnotVector

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for KnotVector

Source§

fn eq(&self, other: &KnotVector) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for KnotVector

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.