From Jason Turner

[c.math.lerp]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpd8ioc89a/{from.md → to.md} +24 -0
tmp/tmpd8ioc89a/{from.md → to.md} RENAMED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Linear interpolation <a id="c.math.lerp">[[c.math.lerp]]</a>
2
+
3
+ ``` cpp
4
+ constexpr float lerp(float a, float b, float t) noexcept;
5
+ constexpr double lerp(double a, double b, double t) noexcept;
6
+ constexpr long double lerp(long double a, long double b, long double t) noexcept;
7
+ ```
8
+
9
+ *Returns:* a+t(b-a).
10
+
11
+ *Remarks:* Let `r` be the value returned. If
12
+ `isfinite(a) && isfinite(b)`, then:
13
+
14
+ - If `t == 0`, then `r == a`.
15
+ - If `t == 1`, then `r == b`.
16
+ - If `t >= 0 && t <= 1`, then `isfinite(r)`.
17
+ - If `isfinite(t) && a == b`, then `r == a`.
18
+ - If `isfinite(t) || !isnan(t) && b-a != 0`, then `!isnan(r)`.
19
+
20
+ Let *`CMP`*`(x,y)` be `1` if `x > y`, `-1` if `x < y`, and `0`
21
+ otherwise. For any `t1` and `t2`, the product of
22
+ *`CMP`*`(lerp(a, b, t2), lerp(a, b, t1))`, *`CMP`*`(t2, t1)`, and
23
+ *`CMP`*`(b, a)` is non-negative.
24
+