Jump to content
  • Advertisement
Sign in to follow this  
Stoic

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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)...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!