# Comparing Quaternions

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

## Recommended Posts

I've been doing some work recently with lots of random rotating elements, and the issue of generally comparing orientations has come up a couple of times. This afternoon, I had the sudden idea that two Unit Quaternions could be compared by simply examining their dot product... I'm primarily interested in knowing the "similarity" of two orientations, and I'm wondering if something like this would work - abs(dot(q1, q2)); The larger the result, the more similar the orientations are, the smaller the result, the more different they are. Is there something terribly wrong with this, or would it work in general? Just trying to start a discussion... thanks for any feedback!

##### Share on other sites
Consider a quaternion q and -q both encode the same rotation. Assuming q is a unit quaternion, q <dot> -q is -1, q <dot> q is 1. Instead, you might want to rotate an arbitrary vector by the two quaternions you want to compare and calculate the dot product of the two vectors.

##### Share on other sites
Just a thought,
Taking SiCrane's suggestion and using the arbitrary vector (1, 1, 1) does the maths simplify to any conventional Quaternion operation?

##### Share on other sites
@SiCrane: but he's got an "abs" around his dot, so abs( dot( q, -q ) ) is 1.

It seems to me that the OP's original algorithm is correct.

##### Share on other sites
@SiCrane - yeah, as emeyex said, the abs was meant to account for the fact that q and -q represent the same orientation. I probably should have stated that in my original post... I'm not sure, however, if quats that are "close" to -q are also "close" to q. I would assume they are, since if q' is close to -q, then -q` is close to q....

Your method of rotating a vector by the two quats would definitely work, although it would be more expensive.

I would also assume that my function doesn't increase linearly as the rotations get more similar. (While SiCrane's would)...

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633731
• Total Posts
3013582
×