6.11 - More Matrix Math Concepts

Before leaving the lessons on transformations, let’s review some important concepts related to matrix algebra.

Order Matters!

In mathematics, if a series of operations can be performed in any order, we say the operations are “commutative.” For example, the multiplication of numbers is commutative because the multiplications can be done in any order.

// These 3 statements calculate the same answer; multiplication of numbers is commutative
a = 3 * 4 * 7 * 10;
b = 10 * 7 * 4 * 3;
c = 4 * 10 * 7 * 3;

However, in matrix algebra, multiplication is NOT commutative. The order of the terms matter. If you change the order, you get a different result.

Matrix Multiplication is Associative

In mathematics, if a series of operations can be grouped in different ways and you still get the same result, the operations are “associative.” For example, multiplication of numbers is associative because the order in which you perform the operations does not matter.

// These 3 statements calculate the same answer; multiplication of numbers is associative
a = (3 * 4) * (7 * 10);
b = 3 * ((4 * 7) * 10);
c = ((3 * 4) * 7) * 10;

In matrix algebra, multiplication is associative! This means that no matter which multiplications you perform first, second, or third, you get the same result. For the following three example equations, if you performed the multiplication in the parentheses first, you get the same result for T.

T =T1
*(T2
*(T3
*T4
)) Eq1
T = (T1
*T2
)*(T3
*T4
) Eq2
T = ((T1
*T2
)*T3
)*T4
) Eq3

The fact that multiplication of matrices is associative is what allows us to combine a series of transformations into a single, 4-by-4 transformation matrix. We could multiply a vertex by a series of individual matrices, but this would be computationally expensive. We get a huge advantage in rendering speed if we combine all of the transformations into a single transform. And so that is what we typically do!

Transforms Are Relative

BUT things are not as simple as they might seem. Conceptually, a programmer must keep the transformations separate because each transform is actually processing a different model! Let’s explain that with an example. Suppose you have a model that is being transformed by five different matrices like this:

T1
*T2
*T3
*T4
*T5
*x
y
z
w
=x'
y'
z'
w'
Eq4

Conceptually, the matrix T5 is applied first to the model and now the model has different values for each of its vertices. The matrix T4 is now transforming the transformed model. This logic applies to each of the succeeding multiplications. To make this idea more concrete, suppose that transform T5 was a scaling operation that is changing the model’s vertices from units of feet to inches. T5 would be this scaling matrix:

T5 =12
0
0
0
0
12
0
0
0
0
12
0
0
0
0
1
Eq5

Since T5 has changed the conceptual units of the model, all of the other transforms must conceptually think in terms of feet, instead of in inches, because they are now acting on the transformed model!

In summary, when you create a transformation matrix, you must consider the transformations that have come before it. We will see more examples of this when we study projection transforms.

Glossary

commutative property
the order that a math operation is performed does not affect the result. (E.g., 3*7 == 7*3). Matrix multiplication is NOT commutative.
associative property
the grouping of math operations does not affect the result of a calculation. (E.g. (3 + 4) + 5 == 3 + (4 + 5)). Matrix multiplication is associative.
Next Section - 6.12 - Coding Issues