Skip to content

mp_units::lerp

Linear interpolation or extrapolation

Synopsis

Declared in <mp-units/math.h>

template<auto R1, auto Origin, typename Rep1, auto R2, typename Rep2, typename Factor>
  requires requires(Rep1 a, Rep2 b, Factor t) {
    get_common_reference(R1, R2);
    requires requires { lerp(a, b, t); }
#if MP_UNITS_HOSTED
               || requires { std::lerp(a, b, t); }
#endif
               ;
  }
[[nodiscard]] constexpr QuantityPointOf<get_quantity_spec(get_common_reference(R1, R2))> auto lerp(
  quantity_point<R1, Origin, Rep1> const& a, quantity_point<R2, Origin, Rep2> const& b, Factor const& t) noexcept;

Description

Computes the linear interpolation between a and b, if the parameter t is inside [​0​, 1)] (the linear extrapolation otherwise), i.e. the result of a + t(b − a) with accounting for floating-point calculation imprecision.

Return Value

Note

The return value should not be discarded.

Parameters

NameDescription
aA quantity point
bA quantity point