pub struct BSpline<T: Interpolate<F> + Copy, F: Float> { /* private fields */ }
Expand description
Represents a B-spline curve that will use polynomials of the specified degree to interpolate between the control points given the knots.
Implementations
sourceimpl<T: Interpolate<F> + Copy, F: Float> BSpline<T, F>
impl<T: Interpolate<F> + Copy, F: Float> BSpline<T, F>
sourcepub fn new(
degree: usize,
control_points: Vec<T>,
knots: Vec<F>
) -> BSpline<T, F>
pub fn new(
degree: usize,
control_points: Vec<T>,
knots: Vec<F>
) -> BSpline<T, F>
Create a new B-spline curve of the desired degree
that will interpolate
the control_points
using the knots
. The knots should be sorted in non-decreasing
order otherwise they will be sorted for you, which may lead to undesired knots
for control points. Note that here we use the interpolating polynomial degree,
if you’re familiar with the convention of “B-spline curve order” the degree is curve_order - 1
.
Your curve must have a valid number of control points and knots or the function will panic. A B-spline
curve requires at least as one more control point than the degree (control_points.len() > degree
) and the number of knots should be equal to control_points.len() + degree + 1
.
sourcepub fn point(&self, t: F) -> T
pub fn point(&self, t: F) -> T
Compute a point on the curve at t
, the parameter must be in the inclusive range
of values returned by knot_domain
. If t
is out of bounds this function will assert
on debug builds and on release builds you’ll likely get an out of bounds crash.
sourcepub fn control_points(&self) -> Iter<'_, T>
pub fn control_points(&self) -> Iter<'_, T>
Get an iterator over the control points.
sourcepub fn knot_domain(&self) -> (F, F)
pub fn knot_domain(&self) -> (F, F)
Get the min and max knot domain values for finding the t
range to compute
the curve over. The curve is only defined over the inclusive range [min, max]
,
passing a t
value outside of this range will result in an assert on debug builds
and likely a crash on release builds.
Trait Implementations
Auto Trait Implementations
impl<T, F> RefUnwindSafe for BSpline<T, F> where
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, F> Send for BSpline<T, F> where
F: Send,
T: Send,
impl<T, F> Sync for BSpline<T, F> where
F: Sync,
T: Sync,
impl<T, F> Unpin for BSpline<T, F> where
F: Unpin,
T: Unpin,
impl<T, F> UnwindSafe for BSpline<T, F> where
F: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more