Struct bevy::math::prelude::RationalCurve
pub struct RationalCurve<P>where
P: VectorSpace,{ /* private fields */ }
Expand description
A collection of RationalSegment
s chained into a single parametric curve.
Use any struct that implements the RationalGenerator
trait to create a new curve, such as
CubicNurbs
, or convert CubicCurve
using into/from
.
Implementations§
§impl<P> RationalCurve<P>where
P: VectorSpace,
impl<P> RationalCurve<P>where
P: VectorSpace,
pub fn position(&self, t: f32) -> P
pub fn position(&self, t: f32) -> P
Compute the position of a point on the 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 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 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(&RationalCurve<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(&RationalCurve<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) -> &[RationalSegment<P>]
pub fn segments(&self) -> &[RationalSegment<P>]
The list of segments contained in this RationalCurve
.
This spline’s global t
value is equal to how many segments it has.
All method accepting t
on RationalCurve
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.
pub fn push_segment(&mut self, segment: RationalSegment<P>)
pub fn push_segment(&mut self, segment: RationalSegment<P>)
Adds a segment to the curve.
Trait Implementations§
§impl<P> Clone for RationalCurve<P>where
P: Clone + VectorSpace,
impl<P> Clone for RationalCurve<P>where
P: Clone + VectorSpace,
§fn clone(&self) -> RationalCurve<P>
fn clone(&self) -> RationalCurve<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 RationalCurve<P>where
P: Debug + VectorSpace,
impl<P> Debug for RationalCurve<P>where
P: Debug + VectorSpace,
§impl<P> Extend<RationalSegment<P>> for RationalCurve<P>where
P: VectorSpace,
impl<P> Extend<RationalSegment<P>> for RationalCurve<P>where
P: VectorSpace,
§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = RationalSegment<P>>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = RationalSegment<P>>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)§impl<P> From<CubicCurve<P>> for RationalCurve<P>where
P: VectorSpace,
impl<P> From<CubicCurve<P>> for RationalCurve<P>where
P: VectorSpace,
§fn from(value: CubicCurve<P>) -> RationalCurve<P>
fn from(value: CubicCurve<P>) -> RationalCurve<P>
§impl<P> IntoIterator for RationalCurve<P>where
P: VectorSpace,
impl<P> IntoIterator for RationalCurve<P>where
P: VectorSpace,
§type IntoIter = <Vec<RationalSegment<P>> as IntoIterator>::IntoIter
type IntoIter = <Vec<RationalSegment<P>> as IntoIterator>::IntoIter
§type Item = RationalSegment<P>
type Item = RationalSegment<P>
§fn into_iter(self) -> <RationalCurve<P> as IntoIterator>::IntoIter
fn into_iter(self) -> <RationalCurve<P> as IntoIterator>::IntoIter
§impl<P> PartialEq for RationalCurve<P>where
P: PartialEq + VectorSpace,
impl<P> PartialEq for RationalCurve<P>where
P: PartialEq + VectorSpace,
§fn eq(&self, other: &RationalCurve<P>) -> bool
fn eq(&self, other: &RationalCurve<P>) -> bool
self
and other
values to be equal, and is used
by ==
.impl<P> StructuralPartialEq for RationalCurve<P>where
P: VectorSpace,
Auto Trait Implementations§
impl<P> Freeze for RationalCurve<P>
impl<P> RefUnwindSafe for RationalCurve<P>where
P: RefUnwindSafe,
impl<P> Send for RationalCurve<P>where
P: Send,
impl<P> Sync for RationalCurve<P>where
P: Sync,
impl<P> Unpin for RationalCurve<P>where
P: Unpin,
impl<P> UnwindSafe for RationalCurve<P>where
P: UnwindSafe,
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> 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>) -> 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
.§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
.§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<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§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> ⓘ
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more