Quaternion Quaternion::GetInverse() const { float mag = magnitude(*this); if (mag != 0) { return GetConjugate() / mag; } else { return *this; } }
cVec3 cQuaternion::GetRotatedVector(const cVec3& value) const { cQuaternion qtemp; qtemp.x = value.x; qtemp.y = value.y; qtemp.z = value.z; qtemp.w = 0; const cQuaternion qout = (*this) * qtemp * GetConjugate(); return cVec3(qout.x, qout.y, qout.z); }
Quaternion Quaternion::GetInverse(){ Quaternion q(GetConjugate()); q.Div(GetNorm()); return q; }