# Game Math: Block Matrices

This post is part of my Game Math Series.

### Splitting Matrices into Blocks

When performing matrix multiplication, we can split matrices into “blocks”. The matrix multiplication can then be performed as if each block is a single matrix element, given that we split the matrices in a way that the multiplication of block matrices are of legal dimensions.

For instance, a product of two 4-by-4 matrices can be viewed as a product of 2-by-2 matrices, where each matrix element is a 2-by-2 block matrix. Since a 2-by-2 matrix can be legally multiplied by another 2-by-2 matrix, such splitting scheme is valid.

Let’s look at an example with numbers:

We can split each of these matrices into four 2-by-2 block matrices:

where , , and .

If we perform the matrix multiplication as if the block matrices are single matrix elements, we get:

We can find out that . If we substitute out in , we get:

We can easily verify that this is the same matrix we will get if we multiply out the matrix product normally.

### Transformation Matrices

In computer graphics, we represent points and vectors as 4D vectors with the component equal to 1 and 0, respectively. We can represent a series of scaling, rotation, and translation as a 4-by-4 matrix in the form:

We can split a 4-by-4 transformation matrix into a 2-by-2 matrix, with the top-left element a 3-by-3 matrix, the top-right element a 3-by-1 matrix, the bottom-left element a 1-by-3 zero matrix, and the bottom-right element the 1-by-1 identity matrix:

where , , , and .

Now if we were to concatenate two transformation matrices:

we can simply perform a 2-by-2 matrix multiplication and get:

You might have seen the formula above before in a book or class on computer graphics. This is one way we can derive this formula, using block matrices.

Using this formula, we can save a lot of computation time if we know beforehand that the two 4-by-4 matrices we are multiplying together are of the form .

### Inverting Transformation Matrices

Splitting matrices into blocks can also help us finding the inverses of matrices. Let’s use the 4-by-4 transformation matrix as an example again:

With careful inspection, we can find that:

We can verify that is correct by performing a block matrix multiplication with :

where is the 3-by-3 identity matrix and is the 4-by-4 identity matrix.

### End of Block Matrices

As you have seen, if we can split matrices in a matrix product into simple block matrices (like identity matrices and zero matrices), we can save a lot of computation time, because many block matrices can possibly be simplified or even zeroed out when multiplied with simple block matrices. The block matrix technique can also help us simplify matrix inversion with matrices in certain forms.