![]() |
| [[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]] |
|
|
#1 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
matrix inversion in general is a slow and tedious process. however in computer graphics we mostly deal with special kinds of matrices that allow for much faster inversion. one such type of matrix is the standard 4 by 4 transformation matrix that contains a rotation and a translation. conveniantly we can invert the rotation and the translation seperatly. the 3x3 rotation matrix is easily inverted by taking the dot product between each pair of row vectors, since it is orthogonal (the vector dot itself is 1 and and 0 for all the others). taking the dot product of the row vectors is equivalent to multiplying the matrix with it's transpose. so the inversion of the rotation part is simply it's transpose
Code:
the translation part is then equally easy inverted (by taking the negative translation and multiplying it with the inverted rotation matrix, which is the transpose we just calculated). Code:
it should be noted that this only works if the matrix is unscaled because the row vectors of the rotation matrix are required to have unit length. the calculation should be extendable though if the matrix is scaled equally in all directions.
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#2 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
i eddited the smileys out because they only showed up as "smiley.gif" when i accessed the code from the front page
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
|
|
#3 | |
|
Member
Join Date: Sep 2004
Location: Copenhagen, Denmark
Posts: 99
|
Quote:
Hmm... dont you need some temp variables for m[3][0] and m[3][1] so you dont use their new updated values when m[3][1] and m[3][2] is computed? |
|
|
|
|
|
|
#4 |
|
DevMaster Staff
Join Date: Apr 2003
Location: Germany
Posts: 2,328
|
right...
i converted the code from my own, which just returns a new matrix so that's how the erorr sneaked in... i will edit it right away. thanks anyway
___________________________________________
If Prolog is the answer, what is the question ? |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|