Matrix from direction and orientation

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

Recommended Posts

I'm not too good at matrices and I've been pouring over a piece of paper trying to work out how to do this to no avail... Basically I have 2 normalised perpendicular vectors, a direction vector and an orientation vector (pointing "downward"). I need a rotation matrix to rotate a cube so its facing the right direction and is the right way up. I'm pretty sure its simple if you know how, can anyone gimme any hints? Additionally, the vectors are always simply of the form (0,1,0), (1,0,0), (-1,0,0), etc, in case that makes it easier.

Share on other sites
you cant define an orientation in 3d with just a vector, use either a 3x3 matrix, euler angles or quaternions.

a homogenous transformation matrix will be a 4x4 matrix with the top left 3x3 being the rotation the 4th column being the translation.

there is lots of material out there to detail exactly how to do it.

Share on other sites
Moved to "Math and Physics".

Share on other sites
The only thing you miss is a "right"-vector. To get it, cross "dir" with "up".

The matrix is
right_x  right_y  right_zup_x     up_y     up_zdir_x    dir_y    dir_z

if you use row-vectors. Transpose it otherwise.

Share on other sites
Quote:
 Original post by jonniiyou cant define an orientation in 3d with just a vector, use either a 3x3 matrix, euler angles or quaternions.a homogenous transformation matrix will be a 4x4 matrix with the top left 3x3 being the rotation the 4th column being the translation.there is lots of material out there to detail exactly how to do it.

read the OP. he has more than one vector.

if you have two peripendicular vectors, constructing a matrix out of them is a joke.

do a crossproduct between these two vectors to obtain a third othonormal vector.

these three vectors are the three column vectors of the matrix you want. just place these vectors in the collumns of a matrix, and there you go. you might need to transpose the matrix depending on how the rest of your code is working, just try it.

Share on other sites
Ah, cheers guys, exactly what I needed, nice one.

1. 1
2. 2
Rutin
21
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633736
• Total Posts
3013602
×