diff --git a/include/zeus/CQuaternion.hpp b/include/zeus/CQuaternion.hpp index b9b3d19..b539f55 100644 --- a/include/zeus/CQuaternion.hpp +++ b/include/zeus/CQuaternion.hpp @@ -274,6 +274,8 @@ public: zeus::CVector3f getImaginary() const { return {x, y, z}; } void setImaginary(const zeus::CVector3f& i) { x = i.x; y = i.y; z = i.z; } + CRelAngle angleFrom(const zeus::CQuaternion& other); + inline float& operator[](size_t idx) { return (&w)[idx]; } inline const float& operator[](size_t idx) const { return (&w)[idx]; } diff --git a/src/CQuaternion.cpp b/src/CQuaternion.cpp index c315b92..9297309 100644 --- a/src/CQuaternion.cpp +++ b/src/CQuaternion.cpp @@ -271,4 +271,10 @@ CQuaternion CQuaternion::buildEquivalent() const else return CQuaternion::fromAxisAngle(CUnitVector3f(x, y, z), tmp + 2.0 * M_PI); } + +CRelAngle CQuaternion::angleFrom(const zeus::CQuaternion& other) +{ + return std::acos(zeus::clamp(-1.f, dot(other), 1.f)); +} + }