Matrices

The Identity Matrix:

Matrices are what make 3d applications tick. If we didn't have matrices, rotation and translation would be impossible. We would have to directly set each vertex in a scene by hand! That is a nasty idea for any programmer with 3d experience. A standard matrix in a 3d world is 4x4.

[1, 0, 0, 0]
[0, 1, 0, 0]
[0, 0, 1, 0]
[0, 0, 0, 1]

If you multiplied a point through the matrix above, it would be equivalent to multiplying it by one- no change would take place. That is called an Identity matrix. Naturally we want a bit more than that, so we also have the...

The Translation Matrix:

tx, ty and tz represent our translation values.

[ 1,  0,  0, 0]
[ 0,  1,  0, 0]
[ 0,  0,  1, 0]
[tx, ty, tz, 1]

The Rotation Matrix:

Rotation on X Axis.

[ 1,         0,          0, 0]
[ 0, cos(xrot), -sin(xrot), 0]
[ 0, sin(xrot),  cos(xrot), 0]
[ 0,         0,          0, 1]

Rotation on Y Axis.

[ cos(yrot), 0, sin(yrot), 0]
[         0, 1,         0, 0]
[-sin(yrot), 0, cos(yrot), 0]
[         0, 0,         0, 1]

Rotation on Z Axis.

[ cos(zrot), -sin(zrot), 0, 0]
[ sin(zrot),  cos(zrot), 0, 0]
[         0,          0, 1, 0]
[         0,          0, 0, 1]

The Scale Matrix:

sx, sy and sz represent our scale values.

[ sx,  0,  0, 0]
[  0, sy,  0, 0]
[  0,  0, sz, 0]
[  0,  0,  0, 1]

You can combine these matrices by multiplying them together. Transforming a point through any of these matrices will have the desired result.

Notice that translation changes the axis for any other operation. If you translated -5, and rotated on the y axis, the center axis will be at 0, 0, -5.

Paul Frazee (The Rainmaker)