Sign in to follow this  

Direct quaternion vector rotation

This topic is 4869 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

Hi, I had a small question about rotating a vector by a quaternion. The quaternion/matrix FAQ on this site in the articles section (at the very end) has the following:
Q63. How do I use quaternions to rotate a vector?
  A rather elegant way to rotate a vector using a quaternion directly is the following (qr being the rotation quaternion):

                       -1
       v' = qr * v * qr

  This can easily be realised and is most likely faster then the transformation using a rotation matrix.
So we define v' the rotated vector, qr is the orientation, v is the source vector, and qr^-1 is qr's inverse. From here, I am lost. Do the *'s represent cross product? or multiplication? And B) quaternions have four elements, vectors three. Doesn't this complicate doing a cross product or even multiplication? And does this imply that v is a four-vector? Previously in my game, I was converting quaternions into matrices to transform vectors. I could see how this would be a lot faster! I've done lots of googling, including looking through mathworld's quat section. I haven't seen this particular method anywhere. Thanks for your time Adam

Share this post


Link to post
Share on other sites
no,i don't think it faster than matrix. In fact,matrix is constructed from
v' = qr * v * qr-1

IIRC, it's 4-vector there... but i'm not really 100% sure.

Share this post


Link to post
Share on other sites
Usually I see that represented as

p' = q * p * q-1

where p is a pure quaternion made from the 3-vector to be rotated. A pure quaternion just takes the vector components as the i, j, and k terms with no scalar quantity or on other notations (0, v). So it becomes the normal multiplication of three quaternions.

In any case, this tends to save a few multiplications and additions compared to converting the quaternion to a full matrix and mulitplying the vector by the matrix. IIRC, if you need to multiply a lot of vectors by the same quaternion, it's still more efficient to convert to a matrix and then multiply all the vectors by the matrix.

(Oh, and mathworld does mention this method. See equation 30 on the quaternion entry.)

Share this post


Link to post
Share on other sites
it is a quaternion multiplication and v is usually a quaternion where the scalar (real) part is zero and the vector (imaginary) part is the vector to rotate.

Share this post


Link to post
Share on other sites

This topic is 4869 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.

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