Fix precision loss on small angles in qua's angle

This commit is contained in:
Quentin Santos 2019-08-31 19:57:46 +02:00
parent c597094980
commit 3a41107d10

View File

@ -1,8 +1,15 @@
#include "scalar_constants.hpp"
namespace glm
{
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER T angle(qua<T, Q> const& x)
{
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);
}
return acos(x.w) * static_cast<T>(2);
}