Files
2025-10-25 03:02:53 +03:00

1.3 KiB
Raw Permalink Blame History

[c.math.lerp]

29 Numerics library [numerics]

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

29.7.4 Linear interpolation [c.math.lerp]

🔗

constexpr floating-point-type lerp(floating-point-type a, floating-point-type b, floating-point-type t) noexcept;

1

#

Returns: a+t(b−a).

2

#

Remarks: Let r be the value returned.

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

  • (2.1)

    If t == 0, then r == a.

  • (2.2)

    If t == 1, then r == b.

  • (2.3)

    If t >= 0 && t <= 1, then isfinite(r).

  • (2.4)

    If isfinite(t) && a == b, then r == a.

  • (2.5)

    If isfinite(t) || !isnan(t) && b - a != 0, then !isnan(r).

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.