# How to rotate a quaternion by a quaternion

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

## Recommended Posts

I'm having trouble rotating a quaternion by a quaternion. I've read several places that to rotate a vector by a quaternion you just create a "pure" quaternion from the vector and perform the following: q * p * p* (q is the quaternion, p is the pure quaternion and q* is q conjugated) Since this is the case I thought maybe that this same operation could be applied to rotate a quaternion like this: q1 * q2 * q1* But this doesn't seem to work. I've also tried just multiplying q1 and q2, but this doesn't do it either, but since quaternions isn't commutative I may be multiplying the wrong way... Can anyone tell me how this is supposed to be done correctly?

##### Share on other sites
You can concatonate the rotations represented by quaternions by multiplying them together. The correct order depends on which rotation you want to happen first.

##### Share on other sites
Say I want to rotate by q1 first then by q2. The way I've tried is q2 * q1. Is this correct?

##### Share on other sites
Quote:
 Original post by LuNoSay I want to rotate by q1 first then by q2. The way I've tried is q2 * q1. Is this correct?

That depends on how your other code is written. If is it written so that a rotation is done like
v' := q2 * q1 * v
then you're right. However, in principle also
v' := v * q2 * q1
is possible (similar to matrix/vector products could be done both ways).

Btw. If you want to check your multiplication:
q1 * q2 = [ r1 * r2 - i1 . i2 ; r1 * i2 + r2 * i1 + i1 x i2 ]
where r denotes the real part and i the imaginery part vector and . means the dot product and x the cross product. Most of this formula is commutative with the exception of the cross product.

##### Share on other sites
It seems I'm doing it correctly so I'll just have to keep looking for possible errors... Thanks for the replies :)

• 37
• 12
• 10
• 10
• 9
×