Trait angular_units::Interpolate
source · pub trait Interpolate: Angle {
fn interpolate<U>(&self, right: &U, pos: Self::Scalar) -> Self
where
U: Clone + IntoAngle<Self, OutputScalar = Self::Scalar>;
fn interpolate_forward<U>(&self, right: &U, pos: Self::Scalar) -> Self
where
U: Clone + IntoAngle<Self, OutputScalar = Self::Scalar>;
}
Expand description
A trait for linear interpolation between angles.
Required Methods§
sourcefn interpolate<U>(&self, right: &U, pos: Self::Scalar) -> Selfwhere
U: Clone + IntoAngle<Self, OutputScalar = Self::Scalar>,
fn interpolate<U>(&self, right: &U, pos: Self::Scalar) -> Selfwhere
U: Clone + IntoAngle<Self, OutputScalar = Self::Scalar>,
Perform a linear interpolation between two angles.
This method will always follow the shortest past between
the two angles. This means it will go backward if the
angles are more than a half turn apart. To force the interpolation
to go forward, use interpolate_forward
.
The output is not normalized, and may exceed a
full turn if it interpolates backward,
even if both inputs are normalized.
The angles may be represented in different units.
sourcefn interpolate_forward<U>(&self, right: &U, pos: Self::Scalar) -> Selfwhere
U: Clone + IntoAngle<Self, OutputScalar = Self::Scalar>,
fn interpolate_forward<U>(&self, right: &U, pos: Self::Scalar) -> Selfwhere
U: Clone + IntoAngle<Self, OutputScalar = Self::Scalar>,
Perform a linear interpolation between two angles,
going forward from self
to right
.
Unlike interpolate
this will always go forward from self
to right
,
even if going backward would take a shorter path. The output is not
normalized, but should remain normalized if both self
and right
are.
The angles may be represented in different units.