emath

Function lerp

source
pub fn lerp<R, T>(range: impl Into<RangeInclusive<R>>, t: T) -> R
where T: Real + Mul<R, Output = R>, R: Copy + Add<R, Output = R>,
Expand description

Linear interpolation.

assert_eq!(lerp(1.0..=5.0, 0.0), 1.0);
assert_eq!(lerp(1.0..=5.0, 0.5), 3.0);
assert_eq!(lerp(1.0..=5.0, 1.0), 5.0);
assert_eq!(lerp(1.0..=5.0, 2.0), 9.0);