From 21b0eb15c849f7ede95be03f8e7669198ea1f089 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Fri, 5 May 2017 19:21:14 -1000 Subject: [PATCH] Add CQuaternion::slerpShort --- include/zeus/CQuaternion.hpp | 1 + src/CQuaternion.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/zeus/CQuaternion.hpp b/include/zeus/CQuaternion.hpp index 6466656..10d549b 100644 --- a/include/zeus/CQuaternion.hpp +++ b/include/zeus/CQuaternion.hpp @@ -256,6 +256,7 @@ public: static CQuaternion lerp(const CQuaternion& a, const CQuaternion& b, double t); static CQuaternion slerp(const CQuaternion& a, const CQuaternion& b, double t); + static CQuaternion slerpShort(const CQuaternion& a, const CQuaternion& b, double t); static CQuaternion nlerp(const CQuaternion& a, const CQuaternion& b, double t); inline float roll() const { return std::atan2(2.f * (x * y + w * z), w * w + x * x - y * y - z * z); } diff --git a/src/CQuaternion.cpp b/src/CQuaternion.cpp index 7634cef..7d7a339 100644 --- a/src/CQuaternion.cpp +++ b/src/CQuaternion.cpp @@ -206,6 +206,11 @@ CQuaternion CQuaternion::slerp(const CQuaternion& a, const CQuaternion& b, doubl return a; } +CQuaternion CQuaternion::slerpShort(const CQuaternion& a, const CQuaternion& b, double t) +{ + return zeus::CQuaternion::slerp((b.dot(a) >= 0.f) ? a : a.buildEquivalent(), b, t); +} + CQuaternion operator+(float lhs, const CQuaternion& rhs) { return CQuaternion(lhs + rhs.w, lhs * rhs.x, lhs * rhs.y, lhs * rhs.z);