Trait Lerp

Source
pub trait Lerp {
    // Required methods
    fn lerp(self, end: Self, percent: f32) -> Self;
    fn inv_lerp(self, end: Self, point: Self) -> f32;
}

Required Methods§

Source

fn lerp(self, end: Self, percent: f32) -> Self

calculate the point at percent between self and end

§Usage
assert_eq!(10.lerp(20, 0.5), 15);
assert_eq!(10.lerp(20, 0.1), 11);

internally the values are cast as f32 and rounded before being returned

Source

fn inv_lerp(self, end: Self, point: Self) -> f32

calculate the percent for point between self and end

§Usage
assert_eq!(10.inv_lerp(20, 15), 0.5);
assert_eq!(10.inv_lerp(20, 11), 0.1);

internally the values are cast as f32 and rounded before being 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.

Implementations on Foreign Types§

Source§

impl Lerp for i8

Source§

fn lerp(self, end: i8, percent: f32) -> i8

Source§

fn inv_lerp(self, end: i8, point: i8) -> f32

Source§

impl Lerp for i16

Source§

fn lerp(self, end: i16, percent: f32) -> i16

Source§

fn inv_lerp(self, end: i16, point: i16) -> f32

Source§

impl Lerp for i32

Source§

fn lerp(self, end: i32, percent: f32) -> i32

Source§

fn inv_lerp(self, end: i32, point: i32) -> f32

Source§

impl Lerp for i64

Source§

fn lerp(self, end: i64, percent: f32) -> i64

Source§

fn inv_lerp(self, end: i64, point: i64) -> f32

Source§

impl Lerp for i128

Source§

fn lerp(self, end: i128, percent: f32) -> i128

Source§

fn inv_lerp(self, end: i128, point: i128) -> f32

Source§

impl Lerp for isize

Source§

fn lerp(self, end: isize, percent: f32) -> isize

Source§

fn inv_lerp(self, end: isize, point: isize) -> f32

Source§

impl Lerp for u8

Source§

fn lerp(self, end: u8, percent: f32) -> u8

Source§

fn inv_lerp(self, end: u8, point: u8) -> f32

Source§

impl Lerp for u16

Source§

fn lerp(self, end: u16, percent: f32) -> u16

Source§

fn inv_lerp(self, end: u16, point: u16) -> f32

Source§

impl Lerp for u32

Source§

fn lerp(self, end: u32, percent: f32) -> u32

Source§

fn inv_lerp(self, end: u32, point: u32) -> f32

Source§

impl Lerp for u64

Source§

fn lerp(self, end: u64, percent: f32) -> u64

Source§

fn inv_lerp(self, end: u64, point: u64) -> f32

Source§

impl Lerp for u128

Source§

fn lerp(self, end: u128, percent: f32) -> u128

Source§

fn inv_lerp(self, end: u128, point: u128) -> f32

Source§

impl Lerp for usize

Source§

fn lerp(self, end: usize, percent: f32) -> usize

Source§

fn inv_lerp(self, end: usize, point: usize) -> f32

Implementors§