splines::interpolate

Trait Interpolate

Source
pub trait Interpolate<T>: Sized + Copy {
    // Required methods
    fn lerp(a: Self, b: Self, t: T) -> Self;
    fn quadratic_bezier(a: Self, u: Self, b: Self, t: T) -> Self;
    fn cubic_bezier(a: Self, u: Self, v: Self, b: Self, t: T) -> Self;

    // Provided method
    fn cubic_hermite(
        _: (Self, T),
        a: (Self, T),
        b: (Self, T),
        _: (Self, T),
        t: T,
    ) -> Self { ... }
}
Expand description

Keys that can be interpolated in between. Implementing this trait is required to perform sampling on splines.

T is the variable used to sample with. Typical implementations use [f32] or [f64], but you’re free to use the ones you like. Feel free to have a look at Spline::sample for instance to know which trait your type must implement to be usable.

Required Methods§

Source

fn lerp(a: Self, b: Self, t: T) -> Self

Linear interpolation.

Source

fn quadratic_bezier(a: Self, u: Self, b: Self, t: T) -> Self

Quadratic Bézier interpolation.

Source

fn cubic_bezier(a: Self, u: Self, v: Self, b: Self, t: T) -> Self

Cubic Bézier interpolation.

Provided Methods§

Source

fn cubic_hermite( _: (Self, T), a: (Self, T), b: (Self, T), _: (Self, T), t: T, ) -> Self

Cubic hermite interpolation.

Default to lerp.

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.

Implementations on Foreign Types§

Source§

impl Interpolate<f32> for f32

Source§

fn lerp(a: Self, b: Self, t: f32) -> Self

Source§

fn cubic_hermite( x: (Self, f32), a: (Self, f32), b: (Self, f32), y: (Self, f32), t: f32, ) -> Self

Source§

fn quadratic_bezier(a: Self, u: Self, b: Self, t: f32) -> Self

Source§

fn cubic_bezier(a: Self, u: Self, v: Self, b: Self, t: f32) -> Self

Source§

impl Interpolate<f32> for f64

Source§

fn lerp(a: Self, b: Self, t: f32) -> Self

Source§

fn cubic_hermite( (x, xt): (Self, f32), (a, at): (Self, f32), (b, bt): (Self, f32), (y, yt): (Self, f32), t: f32, ) -> Self

Source§

fn quadratic_bezier(a: Self, u: Self, b: Self, t: f32) -> Self

Source§

fn cubic_bezier(a: Self, u: Self, v: Self, b: Self, t: f32) -> Self

Source§

impl Interpolate<f64> for f32

Source§

fn lerp(a: Self, b: Self, t: f64) -> Self

Source§

fn cubic_hermite( (x, xt): (Self, f64), (a, at): (Self, f64), (b, bt): (Self, f64), (y, yt): (Self, f64), t: f64, ) -> Self

Source§

fn quadratic_bezier(a: Self, u: Self, b: Self, t: f64) -> Self

Source§

fn cubic_bezier(a: Self, u: Self, v: Self, b: Self, t: f64) -> Self

Source§

impl Interpolate<f64> for f64

Source§

fn lerp(a: Self, b: Self, t: f64) -> Self

Source§

fn cubic_hermite( x: (Self, f64), a: (Self, f64), b: (Self, f64), y: (Self, f64), t: f64, ) -> Self

Source§

fn quadratic_bezier(a: Self, u: Self, b: Self, t: f64) -> Self

Source§

fn cubic_bezier(a: Self, u: Self, v: Self, b: Self, t: f64) -> Self

Implementors§