OGLplus  (0.59.0) a C++ wrapper for rendering APIs

interpolate.hpp
Go to the documentation of this file.
1 #ifndef EAGINE_MATH_INTERPOLATE_HPP
9 #define EAGINE_MATH_INTERPOLATE_HPP
10 
11 #include "constants.hpp"
12 #include "functions.hpp"
13 
14 #ifdef __clang__
15 EAGINE_DIAG_PUSH()
16 EAGINE_DIAG_OFF(double-promotion)
17 #endif
18 
19 namespace eagine::math {
20 //------------------------------------------------------------------------------
24 template <typename T, typename C>
25 static inline auto interpolate_linear(const T& a, const T& b, C coef) {
26  return T((1 - coef) * a + coef * b);
27 }
28 //------------------------------------------------------------------------------
32 template <typename T, typename C>
33 static inline auto lerp(const T& a, const T& b, C coef) {
34  return interpolate_linear(a, b, coef);
35 }
36 //------------------------------------------------------------------------------
41 template <typename T, typename C>
42 static inline auto smooth_lerp(const T& a, const T& b, C coef) {
43  return lerp(a, b, sine_sigmoid01(coef));
44 }
45 //------------------------------------------------------------------------------
49 template <typename T, typename C>
50 static inline auto smooth_oscillate(const T& a, C coef) {
51  return smooth_lerp(-a, a, coef);
52 }
53 //------------------------------------------------------------------------------
54 } // namespace eagine::math
55 
56 #ifdef __clang__
57 EAGINE_DIAG_POP()
58 #endif
59 
60 #endif // EAGINE_MATH_INTERPOLATE_HPP
static auto smooth_lerp(const T &a, const T &b, C coef)
Linear interpolation with coef transformed by sine_sigmoid01.
Definition: interpolate.hpp:42
static auto sine_sigmoid01(T x)
Calculates goniometric sigmoid (cos in interval (0, 1)) of x.
Definition: functions.hpp:150
Math-related code is placed in this namespace.
Definition: eagine.hpp:48
static auto lerp(const T &a, const T &b, C coef)
Same as interpolate_linear.
Definition: interpolate.hpp:33
static auto interpolate_linear(const T &a, const T &b, C coef)
Linear interpolation between a and b.
Definition: interpolate.hpp:25
static auto smooth_oscillate(const T &a, C coef)
Smooth interpolation between negative a and a.
Definition: interpolate.hpp:50

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).