Function tmx_utils::math_utils::lerp
source · pub fn lerp<T: Num + Copy>(a: T, b: T, t: T) -> TExpand description
Linearly interpolates between a and b by t. Does NOT clamp ‘t’ between 0 and 1, allowing for extrapolation.
Examples
assert_eq!(lerp(0, 1, 1), 1);
assert_eq!(lerp(0.0, 1.0, 0.5), 0.5);
assert_eq!(lerp(0.0, 1.0, 2.0), 2.0);
assert_eq!(lerp::<f32>(-1.0, 1.0, 0.5), 0.0); // Can force casting