From 5ddc877a1dc4aea0490982f678ee2894ee7277b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 1 Sep 2016 19:08:53 +0200 Subject: [PATCH] Math: consider magnitude of translation in DualQuaternion::isNormalized(). Fixes the failing tests. --- src/Magnum/Math/DualQuaternion.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Magnum/Math/DualQuaternion.h b/src/Magnum/Math/DualQuaternion.h index d4b6d35d3..d938f8b0e 100644 --- a/src/Magnum/Math/DualQuaternion.h +++ b/src/Magnum/Math/DualQuaternion.h @@ -32,6 +32,7 @@ #include #include "Magnum/Math/Dual.h" +#include "Magnum/Math/Functions.h" #include "Magnum/Math/Matrix4.h" #include "Magnum/Math/Quaternion.h" @@ -254,11 +255,11 @@ template class DualQuaternion: public Dual> { * @todoc Improve the equation as in Quaternion::isNormalized() */ bool isNormalized() const { - /* Comparing dual part classically, as comparing sqrt() of it would - lead to overly strict precision */ + /* Comparing dual part to zero considering the magnitude of the + translation -- the epsilon be much larger for large values. */ Dual a = lengthSquared(); return Implementation::isNormalizedSquared(a.real()) && - TypeTraits::equals(a.dual(), T(0)); + TypeTraits::equalsZero(a.dual(), Math::max(Math::abs(Math::Dual>::dual().vector()).max(), Math::abs(Math::Dual>::dual().scalar()))); } /**