Combined Rotation and Translation using 4x4 matrix.
A 4x4 matrix can represent all affine transformations (including translation, rotation around origin, reflection, glides, scale from origin contraction and expansion, shear, dilation, spiral similarities). On this page we are mostly interested in representing "proper" isometries, that is, translation with rotation.
We can combine two successive rotations about the origin by multiplying their matrices:
|
= |
|
* |
|
We can combine two successive translations by adding their vectors:
|
= |
|
+ |
|
So how can we represent both rotation and translation in one transform matrix?
To do this we put the rotation matrix in columns and rows 0,1 and 2, we put the translation vector in the right column, the bottom row is 0,0,0,1.
r00 | r01 | r02 | t0 |
r10 | r11 | r12 | t1 |
r20 | r21 | r22 | t2 |
0 | 0 | 0 | 1 |
We can use this matrix to transform points or vectors. If we want to transform vectors then we represent it with the 4th row set to zero:
x0 |
x1 |
x2 |
0 |
When multiplied by the above matrix the vector will be rotated only and not effected by the translation value. If however we want to transform points then we represent it with the 4th row set to one:
x0 |
x1 |
x2 |
1 |
This will both rotate and transform the point.
To combine subsequent transforms we multiply the 4x4 matrices together. How is this multiplication of matrices equivalent to addition of the translation vectors?
One way to understand this is to realise that we are using projective geometry (see box on right).
An alternative way to show this is more of a brute force method; we can multiply two matrices representing pure translation and confirm that the translations get added: