Fix precision loss on small angles in qua's angle
This commit is contained in:
parent
c597094980
commit
3a41107d10
@ -1,8 +1,15 @@
|
|||||||
|
#include "scalar_constants.hpp"
|
||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
template<typename T, qualifier Q>
|
template<typename T, qualifier Q>
|
||||||
GLM_FUNC_QUALIFIER T angle(qua<T, Q> const& x)
|
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);
|
return acos(x.w) * static_cast<T>(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user