Inverting a matrix
Multiplying a matrix by its inverse will always result in the identity matrix. An inverted matrix has the opposite mapping of the non-inverted matrix. Not all matrices have an inverse. Only matrices with a non-zero determinant can be inverted.
Inverting matrices is an important operation; the view matrix that is used to transform three-dimensional objects to be displayed on-screen is the inverse of the camera's position and rotation. Another place where inverted matrices become important is skinning, which will be covered in Chapter 10, Mesh Skinning.
Finding the inverse of a matrix is rather complicated as it needs other support functions (such as transpose and adjugate). In this section, you will build these support functions first and then build the inverse function after they have all been built. So firstly, we need to transpose the matrix.
Transpose
To transpose a matrix, flip every element of the matrix across its main diagonal. For example...