Interpolate

Trait Interpolate 

Source
pub trait Interpolate<T>: Sized + Copy {
    // Required methods
    fn step(t: T, threshold: T, a: Self, b: Self) -> Self;
    fn lerp(t: T, a: Self, b: Self) -> Self;
    fn cosine(t: T, a: Self, b: Self) -> Self;
    fn cubic_hermite(
        t: T,
        x: (T, Self),
        a: (T, Self),
        b: (T, Self),
        y: (T, Self),
    ) -> Self;
    fn quadratic_bezier(t: T, a: Self, u: Self, b: Self) -> Self;
    fn cubic_bezier(t: T, a: Self, u: Self, v: Self, b: Self) -> Self;
    fn cubic_bezier_mirrored(t: T, a: Self, u: Self, v: Self, b: Self) -> Self;
}
Expand description

Values that can be interpolated. Implementing this trait is required to perform sampling on splines.

T is the interpolator used to sample with. Typical implementations use f32 or f64.

Required Methods§

Source

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

Step interpolation.

Source

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

Linear interpolation.

Source

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

Cosine interpolation.

Source

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

Cubic hermite interpolation.

Source

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

Quadratic Bézier interpolation.

a is the first point; b is the second point and u is the tangent of a to the curve.

Source

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

Cubic Bézier interpolation.

a is the first point; b is the second point; u is the output tangent of a to the curve and v is the input tangent of b to the curve.

Source

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

Cubic Bézier interpolation – special case for non-explicit second tangent.

This version does the same computation as Interpolate::cubic_bezier but computes the second tangent by inversing it (typical when the next point uses a Bézier interpolation, where input and output tangents are mirrored for the same key).

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

Available on crate features std or num-traits only.
Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl Interpolate<f32> for f64

Available on crate features std or num-traits only.
Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl Interpolate<f64> for f64

Available on crate features std or num-traits only.
Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§