E.V.E
v2022.09.01

◆ lerp

eve::lerp = {}
inlineconstexpr

Computes the linear interpolation.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value T, eve::value U, eve::floating_value V >
eve::common_compatible_t<T, U> lerp(T x, U y, V t) noexcept;
}
constexpr callable_lerp_ lerp
Computes the linear interpolation.
Definition: lerp.hpp:63
Definition: all_of.hpp:22

Parameters

Return value

The value of the interpolation (or extrapolation) between x and y is returned. The call is semantically equivalent to x+t*(y-x).

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wf_t pf = {3, 2.5, -32.7, 1327.43}, qf = {4.2, 1.5, -100.834, 10.02}, tf = {0, 0.1, -3, 1.0};
std::cout << "---- simd" << '\n'
<< " <- pf = " << pf << '\n'
<< " <- qf = " << qf << '\n'
<< " <- tf = " << tf << '\n'
<< " -> lerp(pf, qf, tf) = " << eve::add(pf, qf, tf) << '\n';
double x = 10000, y = 32700, t = 0.5;
std::cout << "---- scalar" << '\n'
<< " <- x = " << x << '\n'
<< " <- y = " << y << '\n'
<< " <- t = " << t << '\n'
<< " -> lerp(x, y, t) = " << eve::add(x, y, t) << '\n';
return 0;
}
constexpr callable_add_ add
Computes the sum of its arguments.
Definition: add.hpp:83
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve::lerp[mask](x, ...) provides a masked version of lerp which is equivalent to if_else(mask, lerp(x, ...), x)

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wf_t pf = {3, 2.5, -32.7, 1327.43}, qf = {4.2, 1.5, -100.834, 10.02}, tf = {0, 0.1, -3, 1.0};
    std::cout << "---- simd" << '\n'
    << " <- pf = " << pf << '\n'
    << " <- qf = " << qf << '\n'
    << " <- tf = " << tf << '\n'
    << " -> lerp[pf > 0](pf, qf, tf) = " << eve::lerp[pf > 0](pf, qf, tf) << '\n';
    return 0;
    }