use super::{CubicSegment, RationalSegment}; use crate::common_traits::{VectorSpace, WithDerivative, WithTwoDerivatives}; use crate::curve::{ derivatives::{SampleDerivative, SampleTwoDerivatives}, Curve, Interval, }; #[cfg(feature = "alloc")] use super::{CubicCurve, RationalCurve}; // -- CubicSegment impl Curve

for CubicSegment

{ #[inline] fn domain(&self) -> Interval { Interval::UNIT } #[inline] fn sample_unchecked(&self, t: f32) -> P { self.position(t) } } impl SampleDerivative

for CubicSegment

{ #[inline] fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative

{ WithDerivative { value: self.position(t), derivative: self.velocity(t), } } } impl SampleTwoDerivatives

for CubicSegment

{ #[inline] fn sample_with_two_derivatives_unchecked(&self, t: f32) -> WithTwoDerivatives

{ WithTwoDerivatives { value: self.position(t), derivative: self.velocity(t), second_derivative: self.acceleration(t), } } } // -- CubicCurve #[cfg(feature = "alloc")] impl Curve

for CubicCurve

{ #[inline] fn domain(&self) -> Interval { // The non-emptiness invariant guarantees that this succeeds. Interval::new(0.0, self.segments.len() as f32) .expect("CubicCurve is invalid because it has no segments") } #[inline] fn sample_unchecked(&self, t: f32) -> P { self.position(t) } } #[cfg(feature = "alloc")] impl SampleDerivative

for CubicCurve

{ #[inline] fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative

{ WithDerivative { value: self.position(t), derivative: self.velocity(t), } } } #[cfg(feature = "alloc")] impl SampleTwoDerivatives

for CubicCurve

{ #[inline] fn sample_with_two_derivatives_unchecked(&self, t: f32) -> WithTwoDerivatives

{ WithTwoDerivatives { value: self.position(t), derivative: self.velocity(t), second_derivative: self.acceleration(t), } } } // -- RationalSegment impl Curve

for RationalSegment

{ #[inline] fn domain(&self) -> Interval { Interval::UNIT } #[inline] fn sample_unchecked(&self, t: f32) -> P { self.position(t) } } impl SampleDerivative

for RationalSegment

{ #[inline] fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative

{ WithDerivative { value: self.position(t), derivative: self.velocity(t), } } } impl SampleTwoDerivatives

for RationalSegment

{ #[inline] fn sample_with_two_derivatives_unchecked(&self, t: f32) -> WithTwoDerivatives

{ WithTwoDerivatives { value: self.position(t), derivative: self.velocity(t), second_derivative: self.acceleration(t), } } } // -- RationalCurve #[cfg(feature = "alloc")] impl Curve

for RationalCurve

{ #[inline] fn domain(&self) -> Interval { // The non-emptiness invariant guarantees the success of this. Interval::new(0.0, self.length()) .expect("RationalCurve is invalid because it has zero length") } #[inline] fn sample_unchecked(&self, t: f32) -> P { self.position(t) } } #[cfg(feature = "alloc")] impl SampleDerivative

for RationalCurve

{ #[inline] fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative

{ WithDerivative { value: self.position(t), derivative: self.velocity(t), } } } #[cfg(feature = "alloc")] impl SampleTwoDerivatives

for RationalCurve

{ #[inline] fn sample_with_two_derivatives_unchecked(&self, t: f32) -> WithTwoDerivatives

{ WithTwoDerivatives { value: self.position(t), derivative: self.velocity(t), second_derivative: self.acceleration(t), } } }