Browse Source

fix: glm::angle() discards the sign of result for angles in range (2*pi-1, 2*pi)

EZForever 5 years ago
parent
commit
a66b782134
1 changed files with 4 additions and 1 deletions
  1. 4 1
      glm/ext/quaternion_trigonometric.inl

+ 4 - 1
glm/ext/quaternion_trigonometric.inl

@@ -7,7 +7,10 @@ namespace glm
 	{
 		if (abs(x.w) > cos_one_over_two<T>())
 		{
-			return asin(sqrt(x.x * x.x + x.y * x.y + x.z * x.z)) * static_cast<T>(2);
+			T const a = asin(sqrt(x.x * x.x + x.y * x.y + x.z * x.z)) * static_cast<T>(2);
+			if(x.w < static_cast<T>(0))
+				return two_pi<T>() - a;
+			return a;
 		}
 
 		return acos(x.w) * static_cast<T>(2);