]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/f64.rs
More lerp tests, altering lerp docs
[rust.git] / library / std / src / f64.rs
index 39c3e587e1f6f22899f69fe03e755696b1bfe746..ff41f999dd56578f0b146f9566fed9d049e69b77 100644 (file)
@@ -881,19 +881,27 @@ pub fn atanh(self) -> f64 {
 
     /// Linear interpolation between `start` and `end`.
     ///
-    /// This enables the calculation of a "smooth" transition between `start` and `end`,
-    /// where start is represented by `self == 0.0` and `end` is represented by `self == 1.0`.
-    ///
-    /// Values below 0.0 or above 1.0 are allowed, and in general this function closely
-    /// resembles the value of `start + self * (end - start)`, plus additional guarantees.
-    ///
-    /// Those guarantees are, assuming that all values are [`finite`]:
-    ///
-    /// * The value at 0.0 is always `start` and the value at 1.0 is always `end` (exactness)
-    /// * If `start == end`, the value at any point will always be `start == end` (consistency)
-    /// * The values will always move in the direction from `start` to `end` (monotonicity)
-    ///
-    /// [`finite`]: #method.is_finite
+    /// This enables linear interpolation between `start` and `end`, where start is represented by
+    /// `self == 0.0` and `end` is represented by `self == 1.0`. This is the basis of all
+    /// "transition", "easing", or "step" functions; if you change `self` from 0.0 to 1.0
+    /// at a given rate, the result will change from `start` to `end` at a similar rate.
+    ///
+    /// Values below 0.0 or above 1.0 are allowed, allowing you to extrapolate values outside the
+    /// range from `start` to `end`. This also is useful for transition functions which might
+    /// move slightly past the end or start for a desired effect. Mathematically, the values
+    /// returned are equivalent to `start + self * (end - start)`, although we make a few specific
+    /// guarantees that are useful specifically to linear interpolation.
+    ///
+    /// These guarantees are:
+    ///
+    /// * If `start` and `end` are [finite], the value at 0.0 is always `start` and the
+    ///   value at 1.0 is always `end`. (exactness)
+    /// * If `start` and `end` are [finite], the values will always move in the direction from
+    ///   `start` to `end` (monotonicity)
+    /// * If `self` is [finite] and `start == end`, the value at any point will always be
+    ///   `start == end`. (consistency)
+    ///
+    /// [finite]: #method.is_finite
     #[must_use = "method returns a new number and does not mutate the original value"]
     #[unstable(feature = "float_interpolation", issue = "71015")]
     pub fn lerp(self, start: f64, end: f64) -> f64 {