Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Difference' between two quaternions

Tags:

I'm working in Ogre, but it's a general quaternion problem.

I have an object, to which I apply a rotation quaternion Q1 initially. Later, I want to make it as if I initially rotated the object by a different quaternion Q2.

How do I calculate the quaternion which will take the object, already rotated by Q1, and align it as if all I did was apply Q2 to the initial/default orientation? I was looking at (s)lerping, but I am not sure if this only valid on orientations rather than rotations?

like image 733
Mr. Boy Avatar asked Nov 18 '09 12:11

Mr. Boy


People also ask

How do you find the difference between two quaternions?

You can do this using quaternion multiplication. To get the difference C between quaternions A and B you do this: C = A * Quaternion. Inverse(B);

Can you subtract quaternions?

Just to clear up some confusion: Yes usually you can add, subtract, multiply and divide quaternions.

How do you know if two quaternions are equal?

Just apply the quaternion to a 3-D vector. If the final result from q1 and q2 is the same, then the quaternion has "same direction".


1 Answers

It sounds like you want the inverse of Q1 times Q2. Transforming by the inverse of Q1 will rotate the object back to its original frame (the initial orientation, as you say), and then transforming by Q2 will rotate it to its new orientation.

Note that the standard definition of a quaternion applies transformations in a right-to-left multiplication order, so you'll want to compute this as Q = Q2*Q1^{-1}.

like image 62
Jim Avatar answered Oct 09 '22 01:10

Jim