Creating a Composite Transformation Matrix.

For this exercise, we want to create a CTM that will first scale a point by (2, 1, 0) then translate it by (1, 2, 3).
The matrices are below:

Scale
x 0 0 0
0 y 0 0
0 0 z 0
0 0 0 1
 =
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
 
Translate
1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1
 =
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1

Remember that when creating a CTM, we reverse the order in which we would do the operations manually. Below is the CTM we must create:

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
 =
T.S
? ? ? ?
? ? ? ?
? ? ? ?
? ? ? ?

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 1,1 = (1 x 2) + (0 x 0) + (0 x 0) + (1 x 0) = (1 x 2) = 2

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 1,2 = (1 x 0) + (0 x 1) + (0 x 0) + (1 x 0) = 0

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 1,3= (1 x 0) + (0 x 1) + (0 x 0) + (1 x 0) = 0

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 1,4= (1 x 0) + (0 x 0) + (0 x 0) + (1 x 1 = (1 x 1) = 1

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

First row done


T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 2,1 = (0 x 2) + (1 x 0) + (0 x 0) + (2 x 0) = 0

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 2,2= (0 x 0) + (1 x 1) + (0 x 0) + (2 x 0) = (1 x 1) = 1

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 2,3= (0 x 0) + (1 x 0) + (0 x 0) + (2 x 0) = 0

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 2,4= (0 x 0) + (1 x 0) + (0 x 0) + (2 x 1) = (2 x 1) = 2

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Second row done


T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 1,3 = (0 x 2) + (0 x 0) + (1 x 0) + (3 x 0) = 0

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 2,3= (0 x 0) + (0 x 1) + (1 x 0) + (3 x 0) = 0

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 3,3= (0 x 0) + (0 x 0) + (1 x 0) + (3 x 0) = 0

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 4,3= (0 x 0) + (0 x 0) + (1 x 0) + (3 x 1) = (3 x 1) = 3

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Third row done


T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 1,4 = (0 x 2) + (0 x 0) + (0 x 0) + (1 x 0) = 0

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 2,4= (0 x 0) + (0 x 1) + (0 x 0) + (1 x 0) = 0

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 3,4= (0 x 0) + (0 x 0) + (0 x 0) + (1 x 0) = 0

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Cell 4,4= (0 x 0) + (0 x 0) + (0 x 0) + (1 x 1) = (1 x 1) = 1

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
=
T.S
2 0 0 1
0 1 0 2
0 0 0 3
0 0 0 1

Fourth row done


Tricks to speed things up:
Now that you know how to create a CTM, you should be able to see that we can examine each stage and reduce the amount of work that must be done. For example, in the scale operation column 3 contains all zero's. Since anything multiplied by zero is zero, and every entry in the CTM for that column will now involve a 'multiply by zero' operation, we can fill this column in the CTM in with zero because know in advance what each operation will result.

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
 =
T.S
? ? ? ?
? ? ? ?
? ? ? ?
? ? ? ?
 =
T.S
? ? 0 ?
? ? 0 ?
? ? 0 ?
? ? 0 ?


Note also that colums with identical patterns of values not exceeding 0 or 1 will be identical in the final CTM:
T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
 =
T.S
? ? 0 ?
? ? 0 ?
? ? 0 ?
? ? 0 ?
 =
T.S
? 0 0 ?
? 1 0 ?
? 0 0 ?
? 0 0 ?

T . S
Translate
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 1 0 0
0 0 0 0
0 0 0 1
 =
T.S
? 0 0 ?
? 1 0 ?
? 0 0 ?
? 0 0 ?
 =
T.S
? 0 0 ?
? 1 0 ?
? 0 0 ?
0 0 0 1

And so on. This doesn't hold true, however, for the pattern below:
T . S
Translate
1 0 0 1
0 2 0 2
0 0 1 3
0 0 0 1
.
Scale
2 0 0 0
0 2 0 0
0 0 0 0
0 0 0 1
 =
T.S
? ? 0 ?
? ? 0 ?
? ? 0 ?
? ? 0 ?
 =
T.S
? 0 0 ?
? 4 0 ?
? 0 0 ?
? 0 0 ?

By identifying patterns and applying a little bit of maths logic, we have cut the number of cells that must worked out from 16 down to 6 (128 (4 multiplications and 4 additions per cell in the 16 cell CTM) operations down to 48!) Remember though, that if in doubt: WORK IT OUT!