Proect wild animals for our home.
esv::lerp is a function object of class esv::lerp_class used to calculate the linear interpolation of two values or points p1 and p2.
lerp(p1, p2, t) = p1 * (1-t) + p2 *t
p1, p2 can be not only floating point values, but also vector, array, or even matrix of floating point values.
It just requires that p1, p2, and t satisfy the following operators:
p1, p2 and t: operator* p1 and p2: operator+, operator-
p1 and p2 must be the same type, t must be floating-type,
See the full requirements of below note.
constexpr auto l = esv::lerp(p1, p2, t);
constexpr auto l = esv::lerp.fn(p1, p2, t);
constexpr auto l = esv::lerp.fn<p_type>(p1, p2, t);
constexpr auto l = esv::lerp.fn<p_type, t_type>(p1, p2, t);
Note | |
---|---|
esv::lerp(p1, p2, t) requires the following condition:
|
#include <esvcpp/core.hpp> #include <esvcpp/numeric.hpp> int main() { constexpr esv::fx32 a = 1.3f; constexpr esv::fx32 b = 6.3f; constexpr auto c = esv::lerp(a, b, 0.43); esv::print(c); }