From 32e57ce8ffb52306c7be2128a1ac29ffca6c11f6 Mon Sep 17 00:00:00 2001 From: Morgan Veyret Date: Sat, 1 Feb 2014 21:05:44 +0100 Subject: [PATCH] Fix dot product clamp range for vector angle functions. --- glm/gtx/vector_angle.inl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/glm/gtx/vector_angle.inl b/glm/gtx/vector_angle.inl index a6af1d39..64713c59 100644 --- a/glm/gtx/vector_angle.inl +++ b/glm/gtx/vector_angle.inl @@ -18,7 +18,7 @@ namespace glm { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'angle' only accept floating-point inputs"); - genType const Angle(acos(clamp(dot(x, y), genType(0), genType(1)))); + genType const Angle(acos(clamp(dot(x, y), genType(-1), genType(1)))); #ifdef GLM_FORCE_RADIANS return Angle; @@ -37,7 +37,7 @@ namespace glm { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'angle' only accept floating-point inputs"); - T const Angle(acos(clamp(dot(x, y), T(0), T(1)))); + T const Angle(acos(clamp(dot(x, y), T(-1), T(1)))); #ifdef GLM_FORCE_RADIANS return Angle; @@ -57,7 +57,7 @@ namespace glm { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'orientedAngle' only accept floating-point inputs"); - T const Dot = clamp(dot(x, y), T(0), T(1)); + T const Dot = clamp(dot(x, y), T(-1), T(1)); #ifdef GLM_FORCE_RADIANS T const Angle(acos(Dot)); @@ -82,7 +82,7 @@ namespace glm { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'orientedAngle' only accept floating-point inputs"); - T const Dot = clamp(dot(x, y), T(0), T(1)); + T const Dot = clamp(dot(x, y), T(-1), T(1)); #ifdef GLM_FORCE_RADIANS T const Angle(acos(Dot));