pub struct RationalSegment<P: VectorSpace> {
pub coeff: [P; 4],
pub weight_coeff: [f32; 4],
pub knot_span: f32,
}Expand description
A segment of a rational cubic curve, used to hold precomputed coefficients for fast interpolation.
It is a Curve with domain [0, 1].
Note that the knot_span is used only by compound curves constructed by chaining these
together.
Fields§
§coeff: [P; 4]The coefficients matrix of the cubic curve.
weight_coeff: [f32; 4]The homogeneous weight coefficients.
knot_span: f32The width of the domain of this segment.
Implementations§
Source§impl<P: VectorSpace<Scalar = f32>> RationalSegment<P>
impl<P: VectorSpace<Scalar = f32>> RationalSegment<P>
Sourcepub fn position(&self, t: f32) -> P
pub fn position(&self, t: f32) -> P
Instantaneous position of a point at parametric value t in [0, 1].
Sourcepub fn velocity(&self, t: f32) -> P
pub fn velocity(&self, t: f32) -> P
Instantaneous velocity of a point at parametric value t in [0, 1].
Sourcepub fn acceleration(&self, t: f32) -> P
pub fn acceleration(&self, t: f32) -> P
Instantaneous acceleration of a point at parametric value t in [0, 1].
Trait Implementations§
Source§impl<P: Clone + VectorSpace> Clone for RationalSegment<P>
impl<P: Clone + VectorSpace> Clone for RationalSegment<P>
Source§fn clone(&self) -> RationalSegment<P>
fn clone(&self) -> RationalSegment<P>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<P: Copy + VectorSpace> Copy for RationalSegment<P>
Source§impl<P: VectorSpace<Scalar = f32>> Curve<P> for RationalSegment<P>
impl<P: VectorSpace<Scalar = f32>> Curve<P> for RationalSegment<P>
Source§fn sample_unchecked(&self, t: f32) -> P
fn sample_unchecked(&self, t: f32) -> P
Sample a point on this curve at the parameter value
t, extracting the associated value.
This is the unchecked version of sampling, which should only be used if the sample time t
is already known to lie within the curve’s domain. Read moreSource§fn sample(&self, t: f32) -> Option<T>
fn sample(&self, t: f32) -> Option<T>
Sample a point on this curve at the parameter value
t, returning None if the point is
outside of the curve’s domain.Source§fn sample_clamped(&self, t: f32) -> T
fn sample_clamped(&self, t: f32) -> T
Sample a point on this curve at the parameter value
t, clamping t to lie inside the
domain of the curve.Source§impl<P: Debug + VectorSpace> Debug for RationalSegment<P>
impl<P: Debug + VectorSpace> Debug for RationalSegment<P>
Source§impl<P: Default + VectorSpace> Default for RationalSegment<P>
impl<P: Default + VectorSpace> Default for RationalSegment<P>
Source§fn default() -> RationalSegment<P>
fn default() -> RationalSegment<P>
Returns the “default value” for a type. Read more
Source§impl<'de, P> Deserialize<'de> for RationalSegment<P>where
P: Deserialize<'de> + VectorSpace,
impl<'de, P> Deserialize<'de> for RationalSegment<P>where
P: Deserialize<'de> + VectorSpace,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<P: VectorSpace> Extend<RationalSegment<P>> for RationalCurve<P>
Available on crate feature alloc only.
impl<P: VectorSpace> Extend<RationalSegment<P>> for RationalCurve<P>
Available on crate feature
alloc only.Source§fn extend<T: IntoIterator<Item = RationalSegment<P>>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = RationalSegment<P>>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<P: VectorSpace> From<CubicSegment<P>> for RationalSegment<P>
impl<P: VectorSpace> From<CubicSegment<P>> for RationalSegment<P>
Source§fn from(value: CubicSegment<P>) -> Self
fn from(value: CubicSegment<P>) -> Self
Converts to this type from the input type.
Source§impl<P: PartialEq + VectorSpace> PartialEq for RationalSegment<P>
impl<P: PartialEq + VectorSpace> PartialEq for RationalSegment<P>
Source§impl<P: VectorSpace<Scalar = f32>> SampleDerivative<P> for RationalSegment<P>
impl<P: VectorSpace<Scalar = f32>> SampleDerivative<P> for RationalSegment<P>
Source§fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative<P>
fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative<P>
Sample this curve at the parameter value
t, extracting the associated value
in addition to its derivative. This is the unchecked version of sampling, which
should only be used if the sample time t is already known to lie within the
curve’s domain. Read moreSource§fn sample_with_derivative(&self, t: f32) -> Option<WithDerivative<T>>
fn sample_with_derivative(&self, t: f32) -> Option<WithDerivative<T>>
Sample this curve’s value and derivative at the parameter value
t, returning
None if the point is outside of the curve’s domain.Source§fn sample_with_derivative_clamped(&self, t: f32) -> WithDerivative<T>
fn sample_with_derivative_clamped(&self, t: f32) -> WithDerivative<T>
Sample this curve’s value and derivative at the parameter value
t, clamping t
to lie inside the domain of the curve.Source§impl<P: VectorSpace<Scalar = f32>> SampleTwoDerivatives<P> for RationalSegment<P>
impl<P: VectorSpace<Scalar = f32>> SampleTwoDerivatives<P> for RationalSegment<P>
Source§fn sample_with_two_derivatives_unchecked(&self, t: f32) -> WithTwoDerivatives<P>
fn sample_with_two_derivatives_unchecked(&self, t: f32) -> WithTwoDerivatives<P>
Sample this curve at the parameter value
t, extracting the associated value
in addition to two derivatives. This is the unchecked version of sampling, which
should only be used if the sample time t is already known to lie within the
curve’s domain. Read moreSource§fn sample_with_two_derivatives(&self, t: f32) -> Option<WithTwoDerivatives<T>>
fn sample_with_two_derivatives(&self, t: f32) -> Option<WithTwoDerivatives<T>>
Sample this curve’s value and two derivatives at the parameter value
t, returning
None if the point is outside of the curve’s domain.Source§fn sample_with_two_derivatives_clamped(&self, t: f32) -> WithTwoDerivatives<T>
fn sample_with_two_derivatives_clamped(&self, t: f32) -> WithTwoDerivatives<T>
Sample this curve’s value and two derivatives at the parameter value
t, clamping t
to lie inside the domain of the curve.Source§impl<P> Serialize for RationalSegment<P>where
P: Serialize + VectorSpace,
impl<P> Serialize for RationalSegment<P>where
P: Serialize + VectorSpace,
impl<P: PartialEq + VectorSpace> StructuralPartialEq for RationalSegment<P>
Auto Trait Implementations§
impl<P> Freeze for RationalSegment<P>where
P: Freeze,
impl<P> RefUnwindSafe for RationalSegment<P>where
P: RefUnwindSafe,
impl<P> Send for RationalSegment<P>where
P: Send,
impl<P> Sync for RationalSegment<P>where
P: Sync,
impl<P> Unpin for RationalSegment<P>where
P: Unpin,
impl<P> UnsafeUnpin for RationalSegment<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for RationalSegment<P>where
P: 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<C, T> CurveExt<T> for Cwhere
C: Curve<T>,
impl<C, T> CurveExt<T> for Cwhere
C: Curve<T>,
Source§fn sample_iter(
&self,
iter: impl IntoIterator<Item = f32>,
) -> impl Iterator<Item = Option<T>>
fn sample_iter( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = Option<T>>
Sample a collection of
n >= 0 points on this curve at the parameter values t_n,
returning None if the point is outside of the curve’s domain. Read moreSource§fn sample_iter_unchecked(
&self,
iter: impl IntoIterator<Item = f32>,
) -> impl Iterator<Item = T>
fn sample_iter_unchecked( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = T>
Sample a collection of
n >= 0 points on this curve at the parameter values t_n,
extracting the associated values. This is the unchecked version of sampling, which should
only be used if the sample times t_n are already known to lie within the curve’s domain. Read moreSource§fn sample_iter_clamped(
&self,
iter: impl IntoIterator<Item = f32>,
) -> impl Iterator<Item = T>
fn sample_iter_clamped( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = T>
Sample a collection of
n >= 0 points on this curve at the parameter values t_n,
clamping t_n to lie inside the domain of the curve. Read moreSource§fn map<S, F>(self, f: F) -> MapCurve<T, S, Self, F>where
F: Fn(T) -> S,
fn map<S, F>(self, f: F) -> MapCurve<T, S, Self, F>where
F: Fn(T) -> S,
Create a new curve by mapping the values of this curve via a function
f; i.e., if the
sample at time t for this curve is x, the value at time t on the new curve will be
f(x).Source§fn reparametrize<F>(self, domain: Interval, f: F) -> ReparamCurve<T, Self, F>
fn reparametrize<F>(self, domain: Interval, f: F) -> ReparamCurve<T, Self, F>
Create a new
Curve whose parameter space is related to the parameter space of this curve
by f. For each time t, the sample from the new curve at time t is the sample from
this curve at time f(t). The given domain will be the domain of the new curve. The
function f is expected to take domain into self.domain(). Read moreSource§fn reparametrize_linear(
self,
domain: Interval,
) -> Result<LinearReparamCurve<T, Self>, LinearReparamError>
fn reparametrize_linear( self, domain: Interval, ) -> Result<LinearReparamCurve<T, Self>, LinearReparamError>
Source§fn reparametrize_by_curve<C>(self, other: C) -> CurveReparamCurve<T, Self, C>
fn reparametrize_by_curve<C>(self, other: C) -> CurveReparamCurve<T, Self, C>
Source§fn graph(self) -> GraphCurve<T, Self>
fn graph(self) -> GraphCurve<T, Self>
Source§fn chain<C>(self, other: C) -> Result<ChainCurve<T, Self, C>, ChainError>where
C: Curve<T>,
fn chain<C>(self, other: C) -> Result<ChainCurve<T, Self, C>, ChainError>where
C: Curve<T>,
Source§fn reverse(self) -> Result<ReverseCurve<T, Self>, ReverseError>
fn reverse(self) -> Result<ReverseCurve<T, Self>, ReverseError>
Source§fn repeat(self, count: usize) -> Result<RepeatCurve<T, Self>, RepeatError>
fn repeat(self, count: usize) -> Result<RepeatCurve<T, Self>, RepeatError>
Source§fn forever(self) -> Result<ForeverCurve<T, Self>, RepeatError>
fn forever(self) -> Result<ForeverCurve<T, Self>, RepeatError>
Source§fn ping_pong(self) -> Result<PingPongCurve<T, Self>, PingPongError>
fn ping_pong(self) -> Result<PingPongCurve<T, Self>, PingPongError>
Source§fn chain_continue<C>(
self,
other: C,
) -> Result<ContinuationCurve<T, Self, C>, ChainError>where
T: VectorSpace,
C: Curve<T>,
fn chain_continue<C>(
self,
other: C,
) -> Result<ContinuationCurve<T, Self, C>, ChainError>where
T: VectorSpace,
C: Curve<T>,
Source§fn samples(
&self,
samples: usize,
) -> Result<impl Iterator<Item = T>, ResamplingError>
fn samples( &self, samples: usize, ) -> Result<impl Iterator<Item = T>, ResamplingError>
Extract an iterator over evenly-spaced samples from this curve. Read more
Source§impl<C, T> CurveResampleExt<T> for C
impl<C, T> CurveResampleExt<T> for C
Source§fn resample<I>(
&self,
segments: usize,
interpolation: I,
) -> Result<SampleCurve<T, I>, ResamplingError>
fn resample<I>( &self, segments: usize, interpolation: I, ) -> Result<SampleCurve<T, I>, ResamplingError>
Resample this
Curve to produce a new one that is defined by interpolation over equally
spaced sample values, using the provided interpolation to interpolate between adjacent samples.
The curve is interpolated on segments segments between samples. For example, if segments is 1,
only the start and end points of the curve are used as samples; if segments is 2, a sample at
the midpoint is taken as well, and so on. Read moreSource§fn resample_auto(
&self,
segments: usize,
) -> Result<SampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
fn resample_auto(
&self,
segments: usize,
) -> Result<SampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
Resample this
Curve to produce a new one that is defined by interpolation over equally
spaced sample values, using automatic interpolation to interpolate between adjacent samples.
The curve is interpolated on segments segments between samples. For example, if segments is 1,
only the start and end points of the curve are used as samples; if segments is 2, a sample at
the midpoint is taken as well, and so on. Read moreSource§fn resample_uneven<I>(
&self,
sample_times: impl IntoIterator<Item = f32>,
interpolation: I,
) -> Result<UnevenSampleCurve<T, I>, ResamplingError>
fn resample_uneven<I>( &self, sample_times: impl IntoIterator<Item = f32>, interpolation: I, ) -> Result<UnevenSampleCurve<T, I>, ResamplingError>
Source§fn resample_uneven_auto(
&self,
sample_times: impl IntoIterator<Item = f32>,
) -> Result<UnevenSampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
fn resample_uneven_auto(
&self,
sample_times: impl IntoIterator<Item = f32>,
) -> Result<UnevenSampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
Resample this
Curve to produce a new one that is defined by automatic interpolation over
samples taken at the given set of times. The given sample_times are expected to contain at least
two valid times within the curve’s domain interval. Read moreSource§impl<T, C> CurveWithDerivative<T> for Cwhere
T: HasTangent,
C: SampleDerivative<T>,
impl<T, C> CurveWithDerivative<T> for Cwhere
T: HasTangent,
C: SampleDerivative<T>,
Source§fn with_derivative(self) -> SampleDerivativeWrapper<C>
fn with_derivative(self) -> SampleDerivativeWrapper<C>
This curve, but with its first derivative included in sampling. Read more
Source§impl<T, C> CurveWithTwoDerivatives<T> for C
impl<T, C> CurveWithTwoDerivatives<T> for C
Source§fn with_two_derivatives(self) -> SampleTwoDerivativesWrapper<C>
fn with_two_derivatives(self) -> SampleTwoDerivativesWrapper<C>
This curve, but with its first two derivatives included in sampling. Read more
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of
self.