Sign in to follow this  
LuNo

How to rotate a quaternion by a quaternion

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


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


Link to post
Share on other sites
Quote:
Original post by LuNo
Say 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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this