View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Angle-axis vector rotation + quaternions

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

8 replies to this topic

### #1David20321  Members

Posted 04 July 2001 - 06:18 PM

I made a simple program where you can rotate around a space-ship like in descent and stuff using quaternions but now I have to figure out how to move forwards... how do I find the vector of which direction the ship is facing? I know how to convert quaternions into angle-axis rotation values but I don''t know how to turn any of them into a vector... Any help would be appreciated. -David-

### #2Timkin  Members

Posted 04 July 2001 - 08:16 PM

Assume that you know the ship is pointing in a direction such that it makes angles theta, phi and psi with your 3 ground based directional axes.

Then, your velocity vector is just:

V = speed*(cos(theta) i + cos(phi) j + cos(psi) k)

where theta is an angle relative to the i basis vector
phi is an angle relative to the j basis vector
psi is an angle relative to the k basis vector

Regards,

Tim

### #3johnb  Members

Posted 04 July 2001 - 08:54 PM

If your quaternion is q and the ship''s forward direction is x (e.g. the x-axis), then just apply the quaternion to x to generate rotated x, i.e. the ship''s forward direction in it''s current rotated state. Mathematically that''s just

x'' = qxq''

where q'' = the conjugate as q and both x'' and x are treated as quaternions for this calculation.

### #4David20321  Members

Posted 05 July 2001 - 06:56 AM

Timkin for that wouldn''t I need to have a euler rotation... I don''t know how to convert quaternions or angle-axis into euler.

Johnb sorry but I''m new to quaternions, do you know where I could find a piece of source code that could apply the quaternion to the vector?

### #5johnb  Members

Posted 05 July 2001 - 09:26 PM

All you need to do is two quaternion products, i.e. first work out qx then multiply the result of this with q'' = the conjugate/inverse of q. Note that the it matters which order you multiply them.

How to multiply quaternions and much more is documented at http://www.gamasutra.com/features/19980703/quaternions_01.htm. There are a few other quaternions articles I''ve not had a look at on Gamedev''s Articles page.

### #6DeltaVee  Members

Posted 06 July 2001 - 12:13 AM

If you are using DX8 there is a bucket load of ''helper'' functions that convert back and forth from quats to axis angles and back again.

Just search for D3DXQuaternionToAxisAngle in the help.

D.V.

### #7David20321  Members

Posted 06 July 2001 - 06:47 AM

How do I multiply a quaternion by a vector though... would the vector just be a quaternion with [0,x,y,z] instead of [x,y,z,w] or something?

-David-

### #8David20321  Members

Posted 07 July 2001 - 07:12 AM

AAAAARGH!

### #9bloemschneif  Members

Posted 07 July 2001 - 08:48 AM

take a shorter look to this excellent tutorial:
click

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.