Skip to content
This repository was archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
quaternion: improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MaEtUgR committed Dec 16, 2018
1 parent 4969078 commit 745ee1e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions matrix/Quaternion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,10 @@ class Quaternion : public Vector<Type, 4>
Quaternion &q = *this;
Vector3<Type> cr = src.cross(dst);
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)) {
Expand All @@ -215,7 +216,7 @@ class Quaternion : public Vector<Type, 4>
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);
Expand Down

0 comments on commit 745ee1e

Please sign in to comment.