Fast Inverse

Started by
1 comment, last by b34r 18 years, 9 months ago
Hi guys. What is the fastest way for find a 3D transform inverse? Such transform is a 4x4 matrix that manages rotations and translations. And, what about if it contains scale too?
"Technocracy Rules With Supremacy" visit: http://gimpact.sourceforge.net
Advertisement
If you know how the transformation matrix was constructed, you can avoid a general inverse by constructing it in 'reverse'. If the original matrix is (using column vectors):

M = T*R*S

Where T = translation, R = rotation, and S = scale, the inverse is:

M-1 = S-1*R-1*T-1

Each of the inverses on the right has a trivial form (ask if you're not sure what they are). If you really want to optimize, you can write a special function to take advantage of all the zero entries.

If you just have a 4x4 transformation matrix, you can always decompose it into a translation matrix T, and a linear transform, call it L. Then:

M-1 = L-1*T-1

If you know that L only contains rotation, you can just invert it by transposition. Otherwise you'll need a general inverse, but only of the 3x3 linear transform, which is cheaper than a full 4x4 inverse.

[Edit: fixed as per b34r's post.]

[Edited by - jyk on July 1, 2005 7:51:01 AM]
Quote:Original post by jyk
If you know that L only contains rotation and perhaps uniform scaling, you can just invert it by transposition. Otherwise you'll need a general inverse, but only of the 3x3 linear transform, which is cheaper than a full 4x4 inverse.


Yes, although transposition will only work for a non-scaling rotation matrix.
You can get the scale vector out of the 3x3 matrix by getting the length of each row vector (if you're using row major matrice), from there it's easy to inverse scale aswel.
Praise the alternative.

This topic is closed to new replies.

Advertisement