Jump to content
  • Advertisement
Sign in to follow this  
Mage2k

Matrix transform concatenations..

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

Hello, I am in the middle of writing a transformation class and have come up on the following question: Given two transforms each with two matrix members (rotation and invRotation), I know that to concatenate the two transformations to obtain a third I can compose the rotations with a simple matrix multiplication. Will the same work with the invRotations? I.E. Give t1 and t2:
t3.rotation = t1.rotation * t2.rotation;

//does
t3.invRotation = t1.invRotation * t2.invRotation;

//or, should I do
t3.invRotation = t3.rotation.inverse();
Also, does the inverse of the inverse of a matrix always equal the original matrix? I wrote some test code that seems to indicate that it does, however, I know that situations like these often only arise in certain situations. Thanks, Mage

Share this post


Link to post
Share on other sites
Advertisement
Quote:
//does
t3.invRotation = t1.invRotation * t2.invRotation;

//or, should I do
t3.invRotation = t3.rotation.inverse();
You probably want the second one. You could write:

t3.rotation = t1.rotation * t2.rotation;
t3.invRotation = t3.rotation.transpose();

Or equivalently (but less efficiently):

t3.rotation = t1.rotation * t2.rotation;
t3.invRotation = t2.invRotation * t1.invRotation;

In general, (AB)-1 = B-1A-1.

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
Note: the transpose is the inverse only as long as you have no scale. (and of course no translation)
Ok, so I've heard this before, but it never occurred to me to use it. Duh, me. However, to clarify, I believe what you are saying by no scale is that the matrix must be orthonormal, orthogonal and normalized. This is luckily no problem as I've already chosen to keep my scale and translation information in separte vectors and use a 3x3 matrix for the rotations.

Mage

<snip> Found answers to the first two edits...

EDIT3: Also, will converting from a normalized quaternion result in an orthonormal matrix?

[Edited by - Mage2k on September 14, 2005 2:02:15 AM]

Share this post


Link to post
Share on other sites
should, if it is converted properly.

*********************************
it must be noted though that there will be roundoff errors that could accamulate if many consecutive multiplications is done, so you might need to re-orthonormalize matrix after doing many matrix multiplications. Same for quaternions, you'll need to re-normalize them.

If your matrix stores rotation only, it is not necessary to store inverse, BTW, as transpose costs nothing to compute. (you can just write methods that multiply by transposed matrix)

Share this post


Link to post
Share on other sites
Quote:
Also, will converting from a normalized quaternion result in an orthonormal matrix?
Minor detail, but a matrix whose rows/columns form an orthonormal basis is referred to as orthogonal. The answer to the question is that yes, the standard method for converting a quaternion to a 3x3 matrix always generates an orthonormal basis (within numerical limits, of course). The most common form of the 'quaternion-to-matrix' function works with unit-length quaternions only, but the code can easily be adapted to create an orthonormal basis from non-unit quaternions as well.

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!