Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Direct quaternion vector rotation

Started by Optus Aug 16, 2004 at 2:42 PM 2 replies 21.1k views
Original Post
Optus
Optus
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
Dmytry
Dmytry
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.
SiCrane
SiCrane
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.)
VolkerG
VolkerG
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.