Jump to content
  • Advertisement
Sign in to follow this  
pondwater

How to ensure affine transformation matrix represents orthogonal vectors

This topic is 2176 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!