# Rotations from direction, up and side vectors

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

## Recommended Posts

I'm currently working on a 3d racing game in Direct3D on my spare time. But I have run into some problems regarding the representation of the graphical object from my body class. The car body class has forward, up and side vectors that are perfectly perpedicular to each other. My graphical object however needs yaw pitch roll rotations to be represented correctly. A quaternion could work as well. I'm quite convinced in that there's a quite straight forward solution for this. I would appreciate every help I possibly could get. Thanks in advance. / Per

##### Share on other sites
Quote:
 Original post by perre75I'm currently working on a 3d racing game in Direct3D on my spare time. But I have run into some problems regarding the representation of the graphical object from my body class.The car body class has forward, up and side vectors that are perfectly perpedicular to each other. My graphical object however needs yaw pitch roll rotations to be represented correctly. A quaternion could work as well.I'm quite convinced in that there's a quite straight forward solution for this. I would appreciate every help I possibly could get.Thanks in advance./ Per
You can get either a quaternion or a set of Euler angles, as needed, by converting the direction vectors to a matrix, and then converting the matrix to a quaternion or Euler-angle triple. (Personally I'd go with a quaternion, if that's an option, as the conversion is less problematic.)

To build a matrix from the direction vectors, simply load the direction vectors into the rows or columns (depending on whether you're using row vectors or column vectors) of the matrix. Which direction vector goes in which row/column will depend on how the object in question is oriented with respect to the cardinal basis vectors in local space.

1. 1
2. 2
3. 3
Rutin
20
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633656
• Total Posts
3013186
×