[][src]Function iter_num_tools::lerp_fn

pub fn lerp_fn<T>(
    from: RangeInclusive<T>,
    to: RangeInclusive<T>
) -> impl Fn(T) -> T where
    T: Mul<Output = T> + Add<Output = T> + Sub<Output = T> + Div<Output = T> + Copy

Creates a function which calculates a linear interpolation from the first range to the second Input to the produced function can be outside of the first range

use iter_num_tools::lerp_fn;
let f = lerp_fn(0.0..=2.0, 20.0..=21.0);
assert_eq!(f(1.0), 20.5);
assert_eq!(f(-1.0), 19.5);