Sign in to follow this  

Matrix from direction and orientation

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

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 this post


Link to post
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 this post


Link to post
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_z
up_x up_y up_z
dir_x dir_y dir_z

if you use row-vectors. Transpose it otherwise.

Share this post


Link to post
Share on other sites
Quote:
Original post by jonnii
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.

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 this post


Link to post
Share on other sites

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