Defined in header <cmath> | ||
|---|---|---|
constexpr float lerp( float a, float b, float t ); | (1) | (since C++20) |
constexpr double lerp( double a, double b, double t ); | (2) | (since C++20) |
constexpr long double lerp( long double a, long double b, long double t ); | (3) | (since C++20) |
constexpr Promoted lerp( Arithmetic1 a, Arithmetic2 b, Arithmetic3 t ); | (4) | (since C++20) |
a+t*(b−a), i.e. the linear interpolation between a and b for the parameter t (or extrapolation, when t is outside the range [0,1]).double. If any other argument is long double, then the return type is long double, otherwise it is double.| a, b, t | - | values of floating-point or integral types |
a+t*(b−a).
When isfinite(a) && isfinite(b), the following properties are guaranteed:
t == 0, the result is equal to a. t == 1, the result is equal to b. t >= 0 && t <= 1, the result is finite. isfinite(t) && a == b, the result is equal to a. isfinite(t) || (!isnan(t) && b-a != 0), the result is not NaN. Let CMP(x,y) be 1 if x > y, -1 if x < y, and 0 otherwise. For any t1 and t2, the product of CMP(lerp(a, b, t2), lerp(a, b, t1)), CMP(t2, t1), and CMP(b, a) is non-negative. (That is, lerp is monotonic.).
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/numeric/lerp