Archived

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

Matrix Inversion

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

Recommended Posts

Can anyone tell me where I can find help on the maths behind a function for Inverting a 4x4 Matrix? I need to make a function to invert a matrix, but I don''t know how. Thanks. One by one, the peguins steal my sanity.

Share on other sites
Look for some tutorials on matrix math or linear algebra. They''re all over the web.

I like pie.

Share on other sites
first transpose the matrix( rows become the columns )
then divide every element by the determinant of the original matrix.

i''m not sure how to go about coding it but that should help get you started.

i got this off the net somewhere, but it was a couple months ago sorry i can''t give you an address.

Share on other sites
Almost, you need to calculate the cofactor for each position of the transposed matrix, and divide that by the determinant.
The cofactor of position i,j is the determinant of the 3x3 matrix obtained by removing row i and column j from the original 4x4.

Share on other sites
Most computer implementations would use elemtary row operations, rather than calculating cofactors, for finding the inverse of a matrix. This is much less computationally expensive, especially on big matrices.

Share on other sites
quote:
Original post by sjelkjd
Almost, you need to calculate the cofactor for each position of the transposed matrix, and divide that by the determinant.
The cofactor of position i,j is the determinant of the 3x3 matrix obtained by removing row i and column j from the original 4x4.

Almost, you multiply the cofactor by (-1) to the power of (i+j).

This is called the adjoint of a matrix.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Share on other sites
quote:
Original post by Bobby-D
Can anyone tell me where I can find help on the maths behind a function for Inverting a 4x4 Matrix? I need to make a function to invert a matrix, but I don't know how. Thanks.

If your 4x4 matrix is a combination of a 3x3 matrix M and a 3 vector V:
T = | M V |    | 0 1 |

(hope the terminology makes sense...)

then
T_inv = | M_inv (-M_inv * V) |        | 0         1        |

And if the 3x3 matrix is just a rotation matrix, then M_inv = transpose(M), which makes things very simple indeed.

[edited by - MrRowl on January 14, 2004 10:10:32 AM]

Share on other sites
If you actually want to code a matrix inversion function and understand why it works, I''d recomend checking out the matrix algebra section at SOS Math. It covers gaussian elimination (which can be used to invert a matrix), and personally I found it to be explained in a very clear manner, so when I actually wrote my matrix inverse function I knew what it was actually doing.

Share on other sites
Knowing Gaussian elimination is helpful for understanding matrix inversion, but I would only recommend it for large matrices. I''d use the

inv (M) = ( 1/det (M) ) adjoint (M)

method for 3x3 or 4x4 matrices.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Share on other sites
quote:
quote:
Original post by sjelkjd
Almost, you need to calculate the cofactor for each position of the transposed matrix, and divide that by the determinant.
The cofactor of position i,j is the determinant of the 3x3 matrix obtained by removing row i and column j from the original 4x4.

Almost, you multiply the cofactor by (-1) to the power of (i+j).

This is called the adjoint of a matrix.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

This method is known as Cramer''s rule. It happens to be EXTREMELY expensive as the matrix gets larger. NOT recommended in practice for large matrices. See the interesting tables in the link below. A computer with teraflops of computing power would require 4 *YEARS* to compute the inverse of a 20x20 matrix using Cramer''s rule!

http://www2.math.uic.edu/~hanson/mcs471/cramers.html

Fortunately, for very small matrices, its not much different from Gaussian Elimination or other methods. As Paradigm Shifter pointed out, the technique is quite fine and good for 3x3 or 4x4 matrices.

Note that for transformation matrices, there are smarter ways.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

1. 1
2. 2
3. 3
4. 4
frob
13
5. 5

• 16
• 13
• 20
• 12
• 19
• Forum Statistics

• Total Topics
632170
• Total Posts
3004549

×