Struct bevy::math::cubic_splines::CubicCurve
pub struct CubicCurve<P>where
P: Point,{ /* private fields */ }
Expand description
A collection of CubicSegment
s chained into a curve.
Implementations§
§impl<P> CubicCurve<P>where
P: Point,
impl<P> CubicCurve<P>where P: Point,
pub 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)
.
pub 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)
.
pub 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)
.
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,
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.
pub 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()
.
pub 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.
pub 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.
pub 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§
§impl<P> Clone for CubicCurve<P>where
P: Clone + Point,
impl<P> Clone for CubicCurve<P>where P: Clone + Point,
§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 more§impl<P> Debug for CubicCurve<P>where
P: Debug + Point,
impl<P> Debug for CubicCurve<P>where P: Debug + Point,
§impl<P> Default for CubicCurve<P>where
P: Default + Point,
impl<P> Default for CubicCurve<P>where P: Default + Point,
§fn default() -> CubicCurve<P>
fn default() -> CubicCurve<P>
§impl<P> PartialEq<CubicCurve<P>> for CubicCurve<P>where
P: PartialEq<P> + Point,
impl<P> PartialEq<CubicCurve<P>> for CubicCurve<P>where P: PartialEq<P> + Point,
§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§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,
§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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
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
.§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§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.§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.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given World
.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for Pwhere
R: Read + ReadEndian<P>,
P: Default,
impl<R, P> ReadPrimitive<R> for Pwhere R: Read + ReadEndian<P>, P: Default,
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.