Struct stroke::bspline::BSpline[][src]

pub struct BSpline<P, F, const K: usize, const C: usize, const O: usize> { /* fields omitted */ }

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). const generic parameters: C: Number of control points K: Number of Knots O: Order of the piecewise function used for interpolation order = degree + 1 While C, K, O relate to each other in the following manner K = C + O where O = D + 1 it does (currently?) not compile using summation of const generic arguments for the backing arrays

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]

pub fn new(
    knots: [F; K],
    control_points: [P; C],
    degree: usize
) -> Option<BSpline<P, F, {K}, {C}, {O}>>
[src]

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]

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

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

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

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

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.