logo back up home forward   further reading more topics »

Maths - Matrix algebra - Inverse 3x3

Notation

On this page we number the matrix elements with two index numbers the first represents the column, the second the row. The index numbers start at 0 as follows:

m00 m10 m20
m01 m11 m21
m02 m12 m22

Other notation conventions are explained on this page.

Description

The invese of a 3x3 matrix is:

[M]-1 = 1/det[M] *
m11*m22 - m12*m21 m02*m21 - m01*m22 m01*m12 - m02*m11
m12*m20 - m10*m22 m00*m22 - m02*m20 m02*m10 - m00*m12
m10*m21 - m11*m20 m01*m20 - m00*m21 m00*m11 - m01*m10

where:

det = m00*m11*m22 + m01*m12*m20 + m02*m10*m21 - m00*m12*m21 - m01*m10*m22 - m02*m11*m20

The following calculator allows you to calculate the inverse for a 3x3 matrix. Enter the values into the matrix and then press "calc inverse " to display the result:

Code

   public void inverse() {
     double det = m00*m11*m22 + m01*m12*m20 + m02*m10*m21 - m00*m12*m21 - m01*m10*m22 - m02*m11*m20;
     m00 = (m11*m22 - m12*m21)/det;
     m01 = (m02*m21 - m01*m22)/det;
     m02 = (m01*m12 - m02*m11)/det;
     m10 = (m12*m20 - m10*m22)/det;
     m11 = (m00*m22 - m02*m20)/det;
     m12 = (m02*m10 - m00*m12)/det;
     m20 = (m10*m21 - m11*m20)/det;
     m21 = (m01*m20 - m00*m21)/det;
     m22 = (m00*m11 - m01*m10)/det;
   }

Further Information


metadata block
see also:
Correspondence about this page
  • Thank you very much to Claus for correction to determinant formula.

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Developing Games in Java

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to the software project, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

cover Dreamweaver HTML editing program.

Can you help?

Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page.

 

Terminology and Notation

Specific to this page here:

 

program

I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here:

http://sourceforge.net/projects/mjbworld/

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2010 Martin John Baker - All rights reserved - privacy policy.