# Comparing quaternion rotations

This topic is 3369 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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).

##### Share on other sites
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.

##### Share on other sites
Thanks guys! It makes more sense now, and the dot product test is awesome.

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 14
• 9
• 9
• 9
• 10
• ### Forum Statistics

• Total Topics
632912
• Total Posts
3009199
• ### Who's Online (See full list)

There are no registered users currently online

×