Implement CQuaternion::angleFrom()

This commit is contained in:
Jack Andersen 2017-10-28 20:21:23 -10:00
parent 0e792b213a
commit 3d377124c1
2 changed files with 8 additions and 0 deletions

View File

@ -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]; }

View File

@ -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));
}
}