Sign in to follow this  

How to ensure affine transformation matrix represents orthogonal vectors

This topic is 1958 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 use a 4x4 affine transformation matrix to represent the location and orientation of objects in 3D space.

It's in my best interest to ensure that the x,y,z vectors (columns 1, 2 and 3) are orthogonal to eachother.

I'm wondering what is efficient way to go about ensuring this.

For example, lets say I have the matrix m set to a particular orientation. I want to now change its z vector to another arbitrary vector. But I want to ensure that it remains orthogonal.

Two methods I can think of would be:

1) Use cross products to redefine the other vectors in terms of the recently changed one:

y = z.cross(y).cross.z
x = z.cross(y);

2) Create the rotation matrix that would be needed to bring the z vector to its new orientation, multiply the entire matrix by it, thus rotating the other vectors as well.

The first method seems like it would be much more efficient, but it will always be redefining the unchanged vectors in terms of eachother. The second method would avoid that but is much less efficient.

Are there any other methods of dealing with this?

Share this post


Link to post
Share on other sites
Why do you want to change one basis vector? If you rotate the object you have to change all of them, i.e., use an actual rotation matrix. If the other two vectors can be chosen arbitrarily, why do you store them anyway?

Share this post


Link to post
Share on other sites
You can "orthogonalize" a set of Linear independence vectors using this: http://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process
It essentially successively eliminates the "non orthogonal" parts of the vectors.

Share this post


Link to post
Share on other sites
You basically just cross (product) two to create a third, then recross the third with the first (or second) one, and normalize them all.

If you start with only one vector you can cross it with an arbitrary up vector (0,1,0) to produce the third, then recross 1 and 3 to overwrite the up vector. Just make sure the original is not the same as the up vector.

Share this post


Link to post
Share on other sites

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