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
Speed Optimisation
The above program is valid for a general 3×3 matrix which will work in all circumstances but when the matrix is being used to represent a rotation (as described on this page) then the matrix carries a lot of redundant information. So if we want to speed up the code on this page then, for this case only, we can take advantage of this redundant information. To invert a pure rotation then we just take the transpose of the 3x3 part of the matrix.
Calculator
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
This site may have errors. Don't use for critical systems.