Matrix transform concatenations..

Started by
4 comments, last by Zakwayda 18 years, 7 months ago
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
---------------------------------------------------There are 10 kinds of people in the world:Those that understand binary, and those that dont...Mage
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.
Note: the transpose is the inverse only as long as you have no scale. (and of course no translation)
enum Bool { True, False, FileNotFound };
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]
---------------------------------------------------There are 10 kinds of people in the world:Those that understand binary, and those that dont...Mage
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)
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.

This topic is closed to new replies.

Advertisement