Browse Source

Merge pull request #1058 from SergeyKrivohatskiy/patch-1

Fix in axisAngle implementation #1058
Christophe 4 years ago
parent
commit
fe9bb21f1f
1 changed files with 10 additions and 2 deletions
  1. 10 2
      glm/gtx/matrix_interpolation.inl

+ 10 - 2
glm/gtx/matrix_interpolation.inl

@@ -78,10 +78,18 @@ namespace glm
 		if (glm::abs(s) < T(0.001))
 			s = static_cast<T>(1);
 		T const angleCos = (m[0][0] + m[1][1] + m[2][2] - static_cast<T>(1)) * static_cast<T>(0.5);
-		if(abs(angleCos - static_cast<T>(1)) < epsilon)
-			angle = pi<T>() * static_cast<T>(0.25);
+		if(angleCos >= static_cast<T>(1.0))
+		{
+			angle = static_cast<T>(0.0);
+		}
+		else if (angleCos <= static_cast<T>(-1.0))
+		{
+			angle = pi<T>();
+		}
 		else
+		{
 			angle = acos(angleCos);
+		}
 		axis.x = (m[1][2] - m[2][1]) / s;
 		axis.y = (m[2][0] - m[0][2]) / s;
 		axis.z = (m[0][1] - m[1][0]) / s;