Struct bevy::math::cubic_splines::CubicCurve
source · pub struct CubicCurve<P>where
P: Point,{ /* private fields */ }
Expand description
A collection of CubicSegment
s chained into a curve.
Use any struct that implements the CubicGenerator
trait to create a new curve, such as
CubicBezier
.
Implementations§
source§impl<P> CubicCurve<P>where
P: Point,
impl<P> CubicCurve<P>where
P: Point,
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<'a, 'b>(
&'b self,
subdivisions: usize,
sample_function: impl FnMut(&CubicCurve<P>, f32) -> P + 'a
) -> impl Iterator<Item = P> + 'awhere
'b: 'a,
pub fn iter_samples<'a, 'b>(
&'b self,
subdivisions: usize,
sample_function: impl FnMut(&CubicCurve<P>, f32) -> P + 'a
) -> impl Iterator<Item = P> + 'awhere
'b: 'a,
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 = n), where n = self.segment_count()
,
returning an iterator evaluating the curve with the supplied sample_function
at each t
.
For subdivisions = 2
, this will split the curve into two lines, or three points, and
return an iterator with 3 items, the three points, one at the start, middle, and end.
sourcepub fn segments(&self) -> &[CubicSegment<P>]
pub fn segments(&self) -> &[CubicSegment<P>]
The list of segments contained in this CubicCurve
.
This spline’s global t
value is equal to how many segments it has.
All method accepting t
on CubicCurve
depends on the global t
.
When sampling over the entire curve, you should either use one of the
iter_*
methods or account for the segment count using curve.segments().len()
.
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 for CubicCurve<P>
impl<P> 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> Debug for CubicCurve<P>
impl<P> Debug for CubicCurve<P>
source§impl<P> PartialEq for CubicCurve<P>
impl<P> PartialEq 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 ==
.impl<P> StructuralPartialEq for CubicCurve<P>where
P: Point,
Auto Trait Implementations§
impl<P> RefUnwindSafe for CubicCurve<P>where
P: RefUnwindSafe,
impl<P> Send for CubicCurve<P>where
P: Send,
impl<P> Sync for CubicCurve<P>where
P: Sync,
impl<P> Unpin for CubicCurve<P>where
P: Unpin,
impl<P> UnwindSafe for CubicCurve<P>where
P: UnwindSafe,
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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
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>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<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>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
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)
&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)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.