#### Archived

This topic is now archived and is closed to further replies.

# Matrix Question

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

## Recommended Posts

Hey, it''s me again. Finally understand what needs to be done to get texture projection working, and one of the most important steps is getting the reverse of the modelview matrix..... I''ve tried reversing the transformations I perform on the modelview matrix (and putting them in the texture matrix, of course), and it looks alright, but whenever the camera rotates, the spotlight sort of moves a little.... I''ve also tried using the transpose of the modelview matrix, but it must not be completely orthogonal, so it gives the same sort of wonky effect on the spot light..... I guess I need to take the true inverse of the modelview matrix, but I''m yet to find some decent code to find the inverse of a matrix... can anyone help? Or does anyone have any cool tricks to quickly finding the inverse of the modelview matrix? -Mr.Oreo

##### Share on other sites
Matrix A is a 3x3 Matrix, it's composed of the followind elements: A[3][3]{{a, b, c}, {d, e, f}, {g, h, i}};

The inverse of Matrix A or A^-1 is as follows:
A^-1 = (1\|A|) * {{e*i-f*h, -(b*1-c*h), b*f-c*e},                    {-(d*i-f*g),a*i-c*g,-(a*f-c*d)},                   {d*h-e*g, -(a*h-b*g), a*e-b*d}} /*this is a 3x3 matrix */

When |A| is the determinant of A or:

det(A)= a(e*i-f*h) - b(d*i-f*g) + c(d*h-e*g)
finding the determinant that way is called expansion by minors (2x2 matrices within the 3x3).

Sorry I couldn't show you in chalkboard matrix notation.

remember that (1\|A|) is a scalar.

[edited by - Californium on January 20, 2003 1:59:38 PM]

##### Share on other sites
Thanks!!!

What about for a 4x4 matrix though? (sorry... I''m a bit new at this)

-Mr.Oreo

##### Share on other sites
This paper might be of help. Its want i based my inverse function on.

www.intel.com/design/pentiumiii/sml/24504301.pdf

You'll probably want to use the solution based on Cramer's rule.

[edited by - lc_gta on January 20, 2003 4:12:05 PM]

##### Share on other sites
good lord, what happened to their gaussian elimination?? i once wrote a rout that was 4 times as small.. the stuff for cramer''s rule seems okay, tho.

earx

• 35
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631355
• Total Posts
2999521
×