喒tfold University College
This module mainly discusses the same subject as: 2Dtransform, but has a coordinate system with three axes as a basis.
It is useful to agree of one way to draw the coordinate system in. In this material all reasoning in space is done in a right hand system.
This means that if I put my right hand vertically down, like in karate, with my fingers along the positive xaxis, and bend the hand towards the yaxis, the thumb will point up along the positive zaxis. 
We use homogeneous coordinates from the beginning. This means that the general transformation matrix is a 4x4 matrix, and that the general vector form is a column vector with four rows.
P2=M感1
x2 m11 m12 m13 m14 x1 y2 m21 m22 m23 m24 y1 z2 = m31 m32 m33 m34 * z1 1  m41 m42 m43 m44 1 
1 0 0 tx 0 1 0 ty 0 0 1 tz 0 0 0 1  
A translation in space is described by tx, ty and tz. It is easy to see that this matrix realizes the equations: x2=x1+tx y2=y1+ty z2=z1+tz 
sx 0 0 0 0 sy 0 0 0 0 sz 0 0 0 0 1 
Scaling in space is described by sx, sy and sz. We see that this matrix realizes the following equations: x2=x1新x y2=y1新y z2=z1新z 
Rotation is a bit more complicated. We define three different basic rotations, one around every axis.
Around the Zaxis cos(v) sin(v) 0 0 sin(v) cos(v) 0 0 0 0 1 0 0 0 0 1 
Around the Xaxis1 0 0 0 0 cos(v) sin(v) 0 0 sin(v) cos(v) 0 0 0 0 1 
Around the Yaxiscos(v) 0 sin(v) 0  0 1 0 0 sin(v) 0 cos(v) 0  0 0 0 1 
The identity matrix
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 
Again we can interpret it as:

Mirroring
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 
We can mirror the different planes by using scaling factor 1 on the axis that is placed normally on the plane. Notice the matrix to the left. It mirrors around the xyplane, and changes the coordinates from a right hand system to a left hand system. 
Projection
1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 
So far we have only concentrated on moving points around in plane and space. Later we will worry about how we can depict space figures on a plane. It can be useful to notice that this can be done with a matrix operation. We can project a point orthogonical down into one of the main planes by using a matrix that scale the axis normally onto the plane with 0. The matrix to the left is a parallel projection down into the xyplane. 
The reasoning we used in the plane can be transferred to space. Again we use the fact that we can make compound transformation matrices that represent compound geometric transformations.
In the plane the situation is well arranged and it is easy to follow the operations graphically. In space this quickly gets complicated, especially when we rotate. A quite demanding exercise, which often is repeated in graphical literature, is rotating around an arbitrary axis. We will not go through the reasoning for this here. It is seldom we need to construct so complicated transformations in our head when we write code. Usually we get away with simpler solutions if we make some rational choices in the description of the objects we want to represent.
Let us use a simple example on rotation around an axis parallel to one of the main axes. We want to rotate the box on the figure 90 degrees around an axis that runs through P and is vertical on the xyplane. The box has side edges of length 1. After the operation the point Q (2,4,4) should end up in Q2(1,3,4), and P(2,3,4) should remain in P2(2,3,4).
With our knowledge about transformations it should be a good strategy to:
We remember from the chapter about 2Dtransformations that we use the matrices in the opposite direction, and multiply from the left. We make the matrix M=T2愛愁1, and find Q'=M想 and P'=M感.
1 0 0 2 0 1 0 0 1 0 0 2 0 1 0 5 M=0 1 0 3*1 0 0 0*0 1 0 3=1 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 1 0 5 2 1 Q2=M*Q=1 0 0 1*4=3 0 0 1 0 4 4 0 0 0 1 1 1 0 1 0 5 2 2 P2=M*P=1 0 0 1*3=3 0 0 1 0 4 4 0 0 0 1 1 1
The figure or the coordinate system
To repeat in short: The reasoning above is based on the following:
We kept the idea about moving the figure. The order of the matrices is the opposite of the geometric logical order, of reasons that we discussed earlier for plane operations.
We can choose to reason in another way that goes better with the logic for the order of operations. It is the following:
With this reasoning the order becomes: M=T2愛愁1 perhaps more logical.
The functions in OpenGL:
glLoadIdentity() glTanslatef(tx,ty,tz) glRotatef(v,x,y,z) glScalef(sx,sy,sz)
Notice that the f in the function names state that the parameters are floating numbers. There are integer number variants of the functions as well. Also notice that glRotate specify both rotation angle (in degrees) and rotation axis. A 30 degrees counterclockwise rotation around the zaxis looks like this:
glRotatef(30.0f,0.0f,0.0f,1.0f)
Again we can choose if we want to the operations like P2=M感, with P and P2 as column vectors or P2=P愚, with P and P2 as row vectors.
If we choose the last variant the respective base matrices become:
Translation 
1 0 0 0 0 1 0 0 0 0 1 0 tx ty tz 1 
Scaling 
sx 0 0 0 0 sy 0 0 0 0 sz 0 0 0 0 1 
Rotation around the zaxis 
cos sin 0 0 sin cos 0 0 0 0 1 0 0 0 0 1 
Rotation around the xaxis 
1 0 0 0 0 cos sin 0 0 sin cos 0 0 0 0 1 
Rotation around the yaxis 
cos 0 sin 0 0 1 0 0 sin 0 cos 0 0 0 0 1 
A lot of graphical literature describes transformations in this way. You can also study transposition of matrices in the module: Algebra.