# Matrix transform concatenations..

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

## 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 on other sites
Quote:
 //doest3.invRotation = t1.invRotation * t2.invRotation;//or, should I dot3.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 on other sites
Note: the transpose is the inverse only as long as you have no scale. (and of course no translation)

##### Share on other sites
Quote:
 Original post by hplus0603Note: 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 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 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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 31
• 16
• 11
• 10
• 12
• ### Forum Statistics

• Total Topics
634116
• Total Posts
3015598
×