Comparison operations
Comparing two quaternions can be done component-wise. Two quaternions can represent the same rotation even if they are not identical on a component level. This happens because a quaternion and its inverse rotate to the same spot but they take different routes:
- Overload the
==
and!=
operators inquat.cpp
. Add the declaration for these functions toquat.h
:bool operator==(const quat& left, const quat& right) { Â Â Â Â return (fabsf(left.x - right.x) <= QUAT_EPSILON && Â Â Â Â Â Â Â Â Â Â Â Â fabsf(left.y - right.y) <= QUAT_EPSILON && Â Â Â Â Â Â Â Â Â Â Â Â fabsf(left.z - right.z) <= QUAT_EPSILON && Â Â Â Â Â Â Â Â Â Â Â Â fabsf(left.w - right.w) <= QUAT_EPSILON); } bool operator!=(const quat& a, const quat& b) { Â Â Â Â return !...