Skip to main content

KnotVec

Struct KnotVec 

Source
pub struct KnotVec<N: ScalarT> { /* private fields */ }
Expand description

Vector of knots in non-decreasing order.

Knot values exist in the parameter space of a NURBS curve. They partition the total 1D parameter range into regions over which the interpolating polynomials of the NURBS curve are active. Thus, in combination with the degree of a NURBS curve, they define the non-uniform B-spline basis functions.

Implementations§

Source§

impl<N: ScalarT> KnotVec<N>

Source

pub fn new(knots: Vec<N>) -> Option<Self>

Creates a new knot vector if possible.

A new knot vector must satisfy the following criteria:

  • it must contain >= 2 elements
  • it must be sorted (non-decreasing)
  • it must represent a non-zero span (the last knot cannot be equal to the first)
§Parameters
  • knots - a vector of knot values in non-decreasing order
§Example
let knots = KnotVec::new(vec![0.0, 0.0, 0.0, 1.0, 1.0, 1.0]).unwrap();
Source

pub fn len(&self) -> usize

Returns the number of knots in the knot vector.

§Example
let knots = KnotVec::new(vec![0.0, 0.0, 1.0, 1.0]).unwrap();
assert_eq!(knots.len(), 4);
Source

pub fn is_clamped(&self, degree: usize) -> bool

Checks if a knot vector is clamped.

A knot vector is clamped if the first knot value is repeated degree + 1 times at the start of the knot vector (ie. its multiplicity is degree + 1), and if the last knot is repeated degree + 1 times at the end of the knot vector.

§Parameters
  • degree - degree of the NURBS curve
Source

pub fn is_empty(&self) -> bool

Checks if the knot vector is empty (always returns false).

Source

pub fn min_u(&self) -> N

Returns the minimum parameter value contained in this knot vector.

Source

pub fn max_u(&self) -> N

Returns the maximum parameter value contained in this knot vector.

Source

pub fn clamp(&self, u: N) -> N

Clamp a parameter value to the allowed range of the parameter.

§Parameters
  • u - the parameter value to clamp in the range min_u <= u <= max_u
Source

pub fn find_span(&self, u: N) -> usize

Finds the index of the span inside the knot vector which contains the parameter value u.

Each pair of knots in the knot vector defines a span. Spans are zero length for knots with a multiplicity > 1. Given a parameter value, u, this function returns the index of the knot span which contains u.

The knot span index, i = knots.find_span(u), which contains u, satisfies the relationship that:

knots[i] <= u < knots[i+1], when u < knots.max_u()
knots[i] < u == knots[i+1], when u == knots.max_u()
§Parameters
  • u - the parameter value for which to find the span
§Examples
let knots = KnotVec::new(vec![0.0, 0.0, 0.5, 1.0, 1.0]).unwrap();
assert_eq!(knots.find_span(0.0), 1);
assert_eq!(knots.find_span(0.6), 2);
assert_eq!(knots.find_span(1.0), 2); // note u=knots.max_u() is a bit special
§Panics

Panics if the parameter u is outside the allowed range of the knot vector.

Trait Implementations§

Source§

impl<N: Clone + ScalarT> Clone for KnotVec<N>

Source§

fn clone(&self) -> KnotVec<N>

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<N: Debug + ScalarT> Debug for KnotVec<N>

Source§

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

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

impl<N: ScalarT> Index<usize> for KnotVec<N>

Source§

type Output = N

The returned type after indexing.
Source§

fn index(&self, i: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<N: PartialEq + ScalarT> PartialEq for KnotVec<N>

Source§

fn eq(&self, other: &KnotVec<N>) -> 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<N: PartialEq + ScalarT> StructuralPartialEq for KnotVec<N>

Auto Trait Implementations§

§

impl<N> Freeze for KnotVec<N>

§

impl<N> RefUnwindSafe for KnotVec<N>
where N: RefUnwindSafe,

§

impl<N> Send for KnotVec<N>
where N: Send,

§

impl<N> Sync for KnotVec<N>
where N: Sync,

§

impl<N> Unpin for KnotVec<N>
where N: Unpin,

§

impl<N> UnsafeUnpin for KnotVec<N>

§

impl<N> UnwindSafe for KnotVec<N>
where N: UnwindSafe,

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<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

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

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

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

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

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V