revier_glam/
float.rs

1/// A trait for extending [`prim@f32`] and [`prim@f64`] with extra methods.
2pub trait FloatExt {
3    /// Performs a linear interpolation between `self` and `rhs` based on the value `t`.
4    ///
5    /// When `t` is `0`, the result will be `self`.  When `t` is `1`, the result
6    /// will be `rhs`. When `t` is outside of the range `[0, 1]`, the result is linearly
7    /// extrapolated.
8    fn lerp(self, rhs: Self, s: Self) -> Self;
9
10    /// Returns `v` normalized to the range `[a, b]`.
11    ///
12    /// When `v` is equal to `a` the result will be `0`.  When `v` is equal to `b` will be `1`.
13    ///
14    /// When `v` is outside of the range `[a, b]`, the result is linearly extrapolated.
15    ///
16    /// `a` and `b` must not be equal, otherwise the result will be either infinite or `NAN`.
17    fn inverse_lerp(a: Self, b: Self, v: Self) -> Self;
18
19    /// Remap `self` from the input range to the output range.
20    ///
21    /// When `self` is equal to `in_start` this returns `out_start`.
22    /// When `self` is equal to `in_end` this returns `out_end`.
23    ///
24    /// When `self` is outside of the range `[in_start, in_end]`, the result is linearly extrapolated.
25    ///
26    /// `in_start` and `in_end` must not be equal, otherwise the result will be either infinite or `NAN`.
27    fn remap(self, in_start: Self, in_end: Self, out_start: Self, out_end: Self) -> Self;
28}