Struct bevy_math::cubic_splines::CubicCurve
source · pub struct CubicCurve<P: Point> { /* private fields */ }
Expand description
A collection of CubicSegment
s chained into a curve.
Implementations§
source§impl<P: Point> CubicCurve<P>
impl<P: Point> CubicCurve<P>
sourcepub fn position(&self, t: f32) -> P
pub fn position(&self, t: f32) -> P
Compute the position of a point on the cubic curve at the parametric value t
.
Note that t
varies from 0..=(n_points - 3)
.
sourcepub fn velocity(&self, t: f32) -> P
pub fn velocity(&self, t: f32) -> P
Compute the first derivative with respect to t at t
. This is the instantaneous velocity of
a point on the cubic curve at t
.
Note that t
varies from 0..=(n_points - 3)
.
sourcepub fn acceleration(&self, t: f32) -> P
pub fn acceleration(&self, t: f32) -> P
Compute the second derivative with respect to t at t
. This is the instantaneous
acceleration of a point on the cubic curve at t
.
Note that t
varies from 0..=(n_points - 3)
.
sourcepub fn iter_samples(
&self,
subdivisions: usize,
sample_function: fn(_: &Self, _: f32) -> P
) -> impl Iterator<Item = P> + '_
pub fn iter_samples( &self, subdivisions: usize, sample_function: fn(_: &Self, _: f32) -> P ) -> impl Iterator<Item = P> + '_
A flexible iterator used to sample curves with arbitrary functions.
This splits the curve into subdivisions
of evenly spaced t
values across the
length of the curve from start (t = 0) to end (t = 1), returning an iterator that evaluates
the curve with the supplied sample_function
at each t
.
Given subdivisions = 2
, this will split the curve into two lines, or three points, and
return an iterator over those three points, one at the start, middle, and end.
sourcepub fn iter_positions(
&self,
subdivisions: usize
) -> impl Iterator<Item = P> + '_
pub fn iter_positions( &self, subdivisions: usize ) -> impl Iterator<Item = P> + '_
Iterate over the curve split into subdivisions
, sampling the position at each step.
sourcepub fn iter_velocities(
&self,
subdivisions: usize
) -> impl Iterator<Item = P> + '_
pub fn iter_velocities( &self, subdivisions: usize ) -> impl Iterator<Item = P> + '_
Iterate over the curve split into subdivisions
, sampling the velocity at each step.
sourcepub fn iter_accelerations(
&self,
subdivisions: usize
) -> impl Iterator<Item = P> + '_
pub fn iter_accelerations( &self, subdivisions: usize ) -> impl Iterator<Item = P> + '_
Iterate over the curve split into subdivisions
, sampling the acceleration at each step.
Trait Implementations§
source§impl<P: Clone + Point> Clone for CubicCurve<P>
impl<P: Clone + Point> Clone for CubicCurve<P>
source§fn clone(&self) -> CubicCurve<P>
fn clone(&self) -> CubicCurve<P>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<P: Default + Point> Default for CubicCurve<P>
impl<P: Default + Point> Default for CubicCurve<P>
source§fn default() -> CubicCurve<P>
fn default() -> CubicCurve<P>
source§impl<P: PartialEq + Point> PartialEq<CubicCurve<P>> for CubicCurve<P>
impl<P: PartialEq + Point> PartialEq<CubicCurve<P>> for CubicCurve<P>
source§fn eq(&self, other: &CubicCurve<P>) -> bool
fn eq(&self, other: &CubicCurve<P>) -> bool
self
and other
values to be equal, and is used
by ==
.