[c.math.lerp] (original) (raw)

26 Numerics library [numerics]

26.8 Mathematical functions for floating-point types [c.math]

26.8.4 Linear interpolation [c.math.lerp]

constexpr float lerp(float a, float b, float t) noexcept;constexpr double lerp(double a, double b, double t) noexcept;constexpr long double lerp(long double a, long double b, long double t) noexcept;

Remarks:Let r be the value returned.

If isfinite(a) && isfinite(b), then:

Let CMP(x,y) be 1 if x > y,-1 if x < y, and 0 otherwise.

For any t1 and t2, the product ofCMP(lerp(a, b, t2), lerp(a, b, t1)),CMP(t2, t1), andCMP(b, a)is non-negative.