This post explains an easy and efficient way to implement the inverse of a 3x3 matrix. It’s based on vector operations like previous posts.

Given a 3x3 matrix:

We construct the following three vectors, one for each row of the matrix:

The inverse of the matrix is:

The expression $\mathbf{v}_1 \cdot (\mathbf{v}_2 \times \mathbf{v}_3)$ is the determinant of $\mathbf{M}$ like explained in a previous post. If the determinant is zero, then the matrix has no inverse. Note that the expression $\mathbf{v}_2 \times \mathbf{v}_3$ appears two times, so it only needs to be calculated once.

Pseudo-code: