## Matrices
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...
[ 1, 0, 0, 0] [ 0, 1, 0, 0] [ 0, 0, 1, 0] [tx, ty, tz, 1]
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]
[ 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. |