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); } || requires { std::lerp(a, b, t); };
}
[[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.
Parameters
Name |
Description |
a |
A quantity point |
b |
A quantity point |
Created with MrDocs