diff --git a/src/Magnum/Math/DualQuaternion.h b/src/Magnum/Math/DualQuaternion.h index 7eed6bf8a..6d998eb41 100644 --- a/src/Magnum/Math/DualQuaternion.h +++ b/src/Magnum/Math/DualQuaternion.h @@ -34,7 +34,6 @@ #include "Magnum/Math/Dual.h" #include "Magnum/Math/Matrix4.h" #include "Magnum/Math/Quaternion.h" -#include "Magnum/Math/Functions.h" namespace Magnum { namespace Math { @@ -70,9 +69,8 @@ template inline DualQuaternion sclerp(const DualQuaternion& norma /* Avoid division by zero */ const T cosHalfAngle = dotResult + normalizedA.real().scalar()*normalizedB.real().scalar(); - if(std::abs(cosHalfAngle) >= T(1)) { - return DualQuaternion{normalizedA.real(), Quaternion{Math::lerp(normalizedA.dual().vector(), normalizedB.dual().vector(), t), T(0)}}; - } + if(std::abs(cosHalfAngle) >= T(1)) + return {normalizedA.real(), {Implementation::lerp(normalizedA.dual().vector(), normalizedB.dual().vector(), t), T(0)}}; /* l + εm = q_A^**q_B, multiplying with -1 ensures shortest path when dot < 0 */ const DualQuaternion diff = normalizedA.quaternionConjugated()*(dotResult < T(0) ? -normalizedB : normalizedB); diff --git a/src/Magnum/Math/Functions.h b/src/Magnum/Math/Functions.h index d9b23ef90..bfa697ec9 100644 --- a/src/Magnum/Math/Functions.h +++ b/src/Magnum/Math/Functions.h @@ -437,10 +437,10 @@ The interpolation for vectors is done as in following, similarly for scalars: @f template inline T lerp(const T& a, const T& b, U t); #else template inline typename std::enable_if::value, T>::type lerp(T a, T b, U t) { - return T((U(1) - t)*a + t*b); + return T(Implementation::lerp(a, b, t)); } template inline typename std::enable_if::value, Vector>::type lerp(const Vector& a, const Vector& b, U t) { - return (U(1) - t)*a + t*b; + return Implementation::lerp(a, b, t); } #endif diff --git a/src/Magnum/Math/Vector.h b/src/Magnum/Math/Vector.h index 409e112a9..c757e9b2b 100644 --- a/src/Magnum/Math/Vector.h +++ b/src/Magnum/Math/Vector.h @@ -50,6 +50,10 @@ namespace Magnum { namespace Math { namespace Implementation { template struct VectorConverter; + /* Needed by DualQuaternion and Functions.h (to avoid dependency between them) */ + template T lerp(const T& a, const T& b, U t) { + return T((U(1) - t)*a + t*b); + } } /** @relatesalso Vector