Added function to generate perspective projections
Added function to build 3D affine transformations

i.e. build a 4x4 matrix from a 3x3 matrix and a 3d vector.
Fixed definition of rotation matrix.
Fixed several of the graphics-related functions.

Rotations and translations were all wrong...