Function rerun::external::eframe::egui::epaint::emath::inverse_lerp

pub fn inverse_lerp<R>(range: RangeInclusive<R>, value: R) -> Option<R>
where R: Copy + PartialEq + Sub<Output = R> + Div<Output = R>,
Expand description

Where in the range is this value? Returns 0-1 if within the range.

Returns <0 if before and >1 if after.

Returns None if the input range is zero-width.

assert_eq!(inverse_lerp(1.0..=5.0, 1.0), Some(0.0));
assert_eq!(inverse_lerp(1.0..=5.0, 3.0), Some(0.5));
assert_eq!(inverse_lerp(1.0..=5.0, 5.0), Some(1.0));
assert_eq!(inverse_lerp(1.0..=5.0, 9.0), Some(2.0));
assert_eq!(inverse_lerp(1.0..=1.0, 3.0), None);