Comparing quaternion rotations

Started by
2 comments, last by Nairou 14 years, 8 months ago
While trying to compare quaternion rotations, I came across a result that doesn't make sense to me. I'm hoping someone here can explain it to me (or point me to a reference that explains it -- I don't know what to call it in order to do a search). Essentially, to break it down to the core issue, I took an identity quaternion: [ 0 0 0 1 ] (in x,y,z,w format) And rotated it 360 degrees (2 * pi). I expected the result to be identity still, as it had come full circle. Instead, I ended up with this: [ 0 0 -3.25841e-007 -1 ] Or, ignoring floating point errors: [ 0 0 0 -1 ] Why did the sign change? Does the sign not matter in this case? How can you reliably compare two quaternions if the signs might arbitrarily not match? Is there a way to "correct" a rotated quaternion so the signs are not so random? Or am I missing something else here? Any input would be appreciated.
Advertisement
A quaternion that represents a rotation of alpha around an axis (x, y, z) has the form: x * sin(alpha/2), y * sin(alpha / 2), z * sin(alpha / 2), cos(alpha/2). For alpha = 0, sin(alpha/2) is 0 and cos(alpha/2) is 1, so gives the quaternion (0, 0, 0, 1). For alpha = 360, sin(alpha/2) is still 0, but cos(alpha/2) is -1, so the quaternion is (0, 0, 0, -1).
The change in sign after one full 360-degree rotation can be seen as the result of lifting a path in the group of 3D rotations SO(3) to its universal covering space SU(2). There are some details here: http://en.wikipedia.org/wiki/SU(2)

You can check if two quaternions are close to each other by checking if the absolute value of their dot product is close to 1.
Thanks guys! It makes more sense now, and the dot product test is awesome.

I also found this article which explained it some as well.

This topic is closed to new replies.

Advertisement