diff options
Diffstat (limited to 'src/math/utils.hpp')
| -rw-r--r-- | src/math/utils.hpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/math/utils.hpp b/src/math/utils.hpp index 5ec5959..5c8c62d 100644 --- a/src/math/utils.hpp +++ b/src/math/utils.hpp @@ -5,6 +5,14 @@ #include <utility> #include "math/vector.hpp" +namespace engine::math { + +struct Vector2; +struct Vector3; +struct Vector4; + +} + namespace engine::math::utils { template<size_t size> struct Vector; @@ -19,6 +27,14 @@ constexpr Vector<vector_size>::type array_to_vec(const std::array<float, vector_ }(std::make_index_sequence<vector_size>()); } +constexpr float lerp(float a, float b, float t) { + return a + t * (b - a); +} + +constexpr float map(float x, float from1, float from2, float to1, float to2) { + return to1 + (x - from1) * (to2 - to1) / (from2 - from1); +} + } #endif // MATH_UTILS_HPP |
