From 90e85225f59a5875a87b8f160033f7188117f071 Mon Sep 17 00:00:00 2001 From: Bram Pieters Date: Thu, 24 Jun 2021 15:03:12 +0200 Subject: [PATCH] Change orientedAngle function --- glm/gtx/vector_angle.inl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/glm/gtx/vector_angle.inl b/glm/gtx/vector_angle.inl index a1f957a59..878160d9a 100644 --- a/glm/gtx/vector_angle.inl +++ b/glm/gtx/vector_angle.inl @@ -20,14 +20,15 @@ namespace glm return acos(clamp(dot(x, y), T(-1), T(1))); } - //! \todo epsilon is hard coded to 0.01 template GLM_FUNC_QUALIFIER T orientedAngle(vec<2, T, Q> const& x, vec<2, T, Q> const& y) { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'orientedAngle' only accept floating-point inputs"); T const Angle(acos(clamp(dot(x, y), T(-1), T(1)))); - if(all(epsilonEqual(y, glm::rotate(x, Angle), T(0.0001)))) + T const partialCross = x.x * y.y - y.x * x.y; + + if (partialCross > T(0)) return Angle; else return -Angle;