Struct stroke::bspline::BSpline [−][src]
General Implementation of a BSpline with choosable degree, control points and knots.
Generic parameters:
P: Generic points 'P' as defined by the Point trait
F: Any float value used for the knots and interpolation (usually the same as the internal generic parameter within P
Implementations
impl<P, F, const K: usize, const C: usize, const O: usize> BSpline<P, F, {K}, {C}, {O}> where
P: Add + Sub + Copy + Add<P, Output = P> + Sub<P, Output = P> + Mul<f64, Output = P> + Point<Scalar = f64>,
F: Float + Into<f64>, [src]
P: Add + Sub + Copy + Add<P, Output = P> + Sub<P, Output = P> + Mul<f64, Output = P> + Point<Scalar = f64>,
F: Float + Into<f64>,
pub fn new(
knots: [F; K],
control_points: [P; C],
degree: usize
) -> Option<BSpline<P, F, {K}, {C}, {O}>>[src]
knots: [F; K],
control_points: [P; C],
degree: usize
) -> Option<BSpline<P, F, {K}, {C}, {O}>>
Create a new B-spline curve that interpolates
the control_points using a piecewise polynomial of degree within intervals specified by the knots.
The knots must be sorted in non-decreasing order, the constructor enforces this which may yield undesired results.
The degree is defined as curve_order - 1.
Desired curve must have a valid number of control points and knots in relation to its degree or the constructor will return None.
A B-Spline curve requires at least 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.
pub fn eval(&self, t: F) -> P[src]
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.
pub fn control_points(&self) -> Iter<'_, P>[src]
Returns an iterator over the control points.
pub fn knots(&self) -> Iter<'_, F>[src]
Returns an iterator over the knots.
pub fn knot_domain(&self) -> (F, F)[src]
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.
pub fn arclen(&self, nsteps: usize) -> F where
f64: Sub<F, Output = F> + Mul<F, Output = F> + Float + Into<F>, [src]
f64: Sub<F, Output = F> + Mul<F, Output = F> + Float + Into<F>,
Approximates the arc length of the curve by flattening it with straight line segments. This approximation is unfeasable if desired accuracy is greater than 2 decimal places
Trait Implementations
impl<P: Clone, F: Clone, const K: usize, const C: usize, const O: usize> Clone for BSpline<P, F, K, C, O>[src]
Auto Trait Implementations
impl<P, F, const K: usize, const C: usize, const O: usize> RefUnwindSafe for BSpline<P, F, K, C, O> where
F: RefUnwindSafe,
P: RefUnwindSafe,
F: RefUnwindSafe,
P: RefUnwindSafe,
impl<P, F, const K: usize, const C: usize, const O: usize> Send for BSpline<P, F, K, C, O> where
F: Send,
P: Send,
F: Send,
P: Send,
impl<P, F, const K: usize, const C: usize, const O: usize> Sync for BSpline<P, F, K, C, O> where
F: Sync,
P: Sync,
F: Sync,
P: Sync,
impl<P, F, const K: usize, const C: usize, const O: usize> Unpin for BSpline<P, F, K, C, O> where
F: Unpin,
P: Unpin,
F: Unpin,
P: Unpin,
impl<P, F, const K: usize, const C: usize, const O: usize> UnwindSafe for BSpline<P, F, K, C, O> where
F: UnwindSafe,
P: UnwindSafe,
F: UnwindSafe,
P: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,