#ifndef MATH_UTILS_HPP #define MATH_UTILS_HPP #include #include #include "math/vector.hpp" namespace engine::math { struct Vector2; struct Vector3; struct Vector4; } namespace engine::math::utils { template struct Vector; template<> struct Vector<2> { using type = engine::math::Vector2; }; template<> struct Vector<3> { using type = engine::math::Vector3; }; template<> struct Vector<4> { using type = engine::math::Vector4; }; template constexpr Vector::type array_to_vec(const std::array& coords) { return [&](std::index_sequence) constexpr -> Vector::type { return { coords[i] ... }; }(std::make_index_sequence()); } 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