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>
impl<N: ScalarT> KnotVec<N>
Sourcepub fn new(knots: Vec<N>) -> Option<Self>
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();Sourcepub fn len(&self) -> usize
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);Sourcepub fn is_clamped(&self, degree: usize) -> bool
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
Sourcepub fn clamp(&self, u: N) -> N
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 rangemin_u <= u <= max_u
Sourcepub fn find_span(&self, u: N) -> usize
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: PartialEq + ScalarT> PartialEq for KnotVec<N>
impl<N: PartialEq + ScalarT> PartialEq for KnotVec<N>
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> 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,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.