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;
}
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
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
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".