diff --git a/openVulkanoCpp/Math/Math.hpp b/openVulkanoCpp/Math/Math.hpp index cfd8cc7..4205600 100644 --- a/openVulkanoCpp/Math/Math.hpp +++ b/openVulkanoCpp/Math/Math.hpp @@ -36,6 +36,22 @@ namespace OpenVulkano::Math { return val * val; } + + // Ensures that a given angle is between 0 and 2 pi + template>> + constexpr T NormalizeAngleRad(T angle) + { + constexpr T PIX2 = 2 * std::numbers::pi; + while (angle < 0) + { + angle += PIX2; + } + while (angle >= PIX2) + { + angle -= PIX2; + } + return angle; + } } template using Matrix2_SIMD = glm::tmat2x2;