From 3a41107d1022ca2e6eee5a25740025dc127e7359 Mon Sep 17 00:00:00 2001 From: Quentin Santos Date: Sat, 31 Aug 2019 19:57:46 +0200 Subject: [PATCH] Fix precision loss on small angles in qua's angle --- glm/ext/quaternion_trigonometric.inl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/glm/ext/quaternion_trigonometric.inl b/glm/ext/quaternion_trigonometric.inl index 0c0bf63f..06b7c4c3 100644 --- a/glm/ext/quaternion_trigonometric.inl +++ b/glm/ext/quaternion_trigonometric.inl @@ -1,8 +1,15 @@ +#include "scalar_constants.hpp" + namespace glm { template GLM_FUNC_QUALIFIER T angle(qua const& x) { + if (abs(x.w) > cos_one_over_two()) + { + return asin(sqrt(x.x * x.x + x.y * x.y + x.z * x.z)) * static_cast(2); + } + return acos(x.w) * static_cast(2); }