bevy_math::curve::iterable

Trait IterableCurve

Source
pub trait IterableCurve<T> {
    // Required methods
    fn domain(&self) -> Interval;
    fn sample_iter_unchecked(&self, t: f32) -> impl Iterator<Item = T>;

    // Provided methods
    fn sample_iter_clamped(&self, t: f32) -> impl Iterator<Item = T> { ... }
    fn sample_iter(&self, t: f32) -> Option<impl Iterator<Item = T>> { ... }
}
Available on crate feature curve only.
Expand description

A curve which provides samples in the form of Iterators.

This is an abstraction that provides an interface for curves which look like Curve<Vec<T>> but side-stepping issues with allocation on sampling. This happens when the size of an output array cannot be known statically.

Required Methods§

Source

fn domain(&self) -> Interval

The interval over which this curve is parametrized.

Source

fn sample_iter_unchecked(&self, t: f32) -> impl Iterator<Item = T>

Sample a point on this curve at the parameter value t, producing an iterator over values. This is the unchecked version of sampling, which should only be used if the sample time t is already known to lie within the curve’s domain.

Values sampled from outside of a curve’s domain are generally considered invalid; data which is nonsensical or otherwise useless may be returned in such a circumstance, and extrapolation beyond a curve’s domain should not be relied upon.

Provided Methods§

Source

fn sample_iter_clamped(&self, t: f32) -> impl Iterator<Item = T>

Sample this curve at a specified time t, producing an iterator over sampled values. The parameter t is clamped to the domain of the curve.

Source

fn sample_iter(&self, t: f32) -> Option<impl Iterator<Item = T>>

Sample this curve at a specified time t, producing an iterator over sampled values. If the parameter t does not lie in the curve’s domain, None is returned.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> IterableCurve<T> for ConstantCurve<Vec<T>>
where T: Clone,