diff --git a/matrix/Quaternion.hpp b/matrix/Quaternion.hpp index 18fc2d68c5a..29e711dc46e 100644 --- a/matrix/Quaternion.hpp +++ b/matrix/Quaternion.hpp @@ -195,9 +195,10 @@ public: Quaternion &q = *this; Vector3 cr = src.cross(dst); const float dt = src.dot(dst); - /* If the two vectors are parallel, cross product is zero - * If they point opposite, the dot product is negative */ if (cr.norm() < eps && dt < 0) { + // handle corner cases with 180 degree rotations + // if the two vectors are parallel, cross product is zero + // if they point opposite, the dot product is negative cr = src.abs(); if (cr(0) < cr(1)) { if (cr(0) < cr(2)) { @@ -215,7 +216,7 @@ public: q(0) = Type(0); cr = src.cross(cr); } else { - /* Half-Way Quaternion Solution */ + // normal case, do half-way quaternion solution q(0) = dt + sqrt(src.norm_squared() * dst.norm_squared()); } q(1) = cr(0);