From d1f222d8d9eb4a5fefe9be0399d4459e1b125868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 22 Feb 2013 12:20:17 +0100 Subject: [PATCH] Math: don't include Functions.h in Quaternion only for T squared. --- src/Math/DualQuaternion.h | 2 +- src/Math/Quaternion.h | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Math/DualQuaternion.h b/src/Math/DualQuaternion.h index c83611238..869f4dd0d 100644 --- a/src/Math/DualQuaternion.h +++ b/src/Math/DualQuaternion.h @@ -226,7 +226,7 @@ template class DualQuaternion: public Dual> { * @f] */ inline DualQuaternion inverted() const { - return quaternionConjugated()/Math::pow<2>(length()); + return quaternionConjugated()/pow2(length()); } /** diff --git a/src/Math/Quaternion.h b/src/Math/Quaternion.h index 8fe41b9db..1f2e02178 100644 --- a/src/Math/Quaternion.h +++ b/src/Math/Quaternion.h @@ -23,7 +23,6 @@ #include #include -#include "Math/Functions.h" #include "Math/MathTypeTraits.h" #include "Math/Matrix.h" #include "Math/Vector3.h" @@ -198,7 +197,7 @@ template class Quaternion { CORRADE_ASSERT(MathTypeTraits::equals(dot(), T(1)), "Math::Quaternion::rotationAxis(): quaternion must be normalized", {}); - return _vector/std::sqrt(1-pow<2>(_scalar)); + return _vector/std::sqrt(1-pow2(_scalar)); } /** @@ -208,15 +207,15 @@ template class Quaternion { */ Matrix<3, T> matrix() const { return { - Vector<3, T>(T(1) - 2*pow<2>(_vector.y()) - 2*pow<2>(_vector.z()), + Vector<3, T>(T(1) - 2*pow2(_vector.y()) - 2*pow2(_vector.z()), 2*_vector.x()*_vector.y() + 2*_vector.z()*_scalar, 2*_vector.x()*_vector.z() - 2*_vector.y()*_scalar), Vector<3, T>(2*_vector.x()*_vector.y() - 2*_vector.z()*_scalar, - T(1) - 2*pow<2>(_vector.x()) - 2*pow<2>(_vector.z()), + T(1) - 2*pow2(_vector.x()) - 2*pow2(_vector.z()), 2*_vector.y()*_vector.z() + 2*_vector.x()*_scalar), Vector<3, T>(2*_vector.x()*_vector.z() + 2*_vector.y()*_scalar, 2*_vector.y()*_vector.z() - 2*_vector.x()*_scalar, - T(1) - 2*pow<2>(_vector.x()) - 2*pow<2>(_vector.y())) + T(1) - 2*pow2(_vector.x()) - 2*pow2(_vector.y())) }; } @@ -430,6 +429,11 @@ template class Quaternion { } private: + /* Used to avoid including Functions.h */ + inline constexpr static T pow2(T value) { + return value*value; + } + /* Used in angle() and slerp() (no assertions) */ inline static T angleInternal(const Quaternion& normalizedA, const Quaternion& normalizedB) { return std::acos(dot(normalizedA, normalizedB));