PDA

View Full Version : Fast Inverse Matrix ?

nicolasbol
11-14-2009, 12:08 AM
I do my lighthing calculation in model space and hence hace to transform the light pos from world to model space fast.

The model transformation is basically M = [T] * [R]

Given a matrix:

Xaxisx YAxisx ZAxisx Translationx
Xaxisy YAxisy ZAxisy Translationy
Xaxisz YAxisz ZAxisz Translationz
0 0 0 1

I wonder if a shortcut would be valid:

Xaxisx XAxisy XAxisz -Translationx
Yaxisx YAxisy YAxisz -Translationy
Zaxisx ZAxisy ZAxisz -Translationz
0 0 0 1

Or do I have to do M = [R]-1 * [T]-1

mfort
11-14-2009, 02:05 AM
yes, algebra allows that as far as R is orthogonal.

Godlike
11-16-2009, 12:53 AM
I believe that the inverted of a transformation matrix is:

R' = transpose(R)
M = R' * (- (R' * T))

where R is the rotation part of the transformation matrix (the one with the Xaxisx etc) and T is the translation part (Translationx, Translationy, Translationz)

DmitryM
11-16-2009, 06:48 AM
This like contains the answer:
http://gpwiki.org/index.php/MathGem:Fast_Matrix_Inversion