TheAtlasEngine
 
Loading...
Searching...
No Matches
math.hpp
1#include <functional>
2#include <glm/detail/qualifier.hpp>
3#include <glm/fwd.hpp>
4
5namespace atlas {
6
8 public:
9 template<typename T>
10 static T linear_interpolate(T start,
11 T end,
12 const std::function<float(float)>& function,
13 float t) {
14 float l_adjusted_time = 0.0f;
15 if (!function) {
16 l_adjusted_time = t;
17 }
18 else {
19 const float f = function(t);
20 l_adjusted_time = f;
21 }
22 if (l_adjusted_time < 0) {
23 l_adjusted_time = 0.0f;
24 }
25 if (l_adjusted_time > 1.0f) {
26 l_adjusted_time = 1.0f;
27 }
28
29 float time_dif = 1.0f - l_adjusted_time;
30
31 return start * time_dif + end * l_adjusted_time;
32 }
33
34 private:
35 interpolation() = default;
36 };
37}; // namespace atlas
Definition math.hpp:7