Introduction to Computer Graphics
Lecture 5
3-D Affine Transformations & Projections
Don Herbison-Evans
donherbisonevans@yahoo.com
(updated 8 November 2006)
Basic Transformations
About y axis:
x2 = x1*cos(b) + z1*sin(b)
z2 = - x1*sin(b) + z1*cos(b)
About z axis:
x2 = x1*cos(c) + y1*sin(c)
y2 = - x1*sin(c) + y1*cos(c)
General rotation:
x2 = r[0][0]*x1 + r[1][0]*y1
+ r[2][0]*z1
y2 = r[0][1]*x1 + r[1][1]*y1
+ r[2][1]*z1
z2 = r[0][2]*x1 + r[1][2]*y1
+ r[2][2]*z1
where the sum of the squares of the r[i][j] of any row or column = 1
Note that rotations do not commute, eg
Rx.Ry != Ry.Rx
Unification
Augment each point to be a 4D row vector by adding a fourth unit coordinate :
All 5 transformations can then be performed using a 4x4 array of 16 coefficients
with m[3][0] = 0; m[3][1] = 0; m[3][2] = 0; m[3][3] = 1;
and the remaining 12 coefficients doing all the work.
Projections
Redundancy Problems in Rotations
A general rotation in 3 dimensions has 3 degrees of freedom, but its rotation matrix has 9 free elements. So after a number of calculations, the accumulated round-off errors can make the matrix bad. This can fixed or avoided by various strategies:
| ( | cb*cc | cb*sc | -sb | ) | |
| Rx(a).Ry(b).Rz(c) = | ( | -ca*sc-sa*sb*cc | ca*cc-sa*sb*sc | -sa*cb | ) |
| ( | -sa*sc+ca*sb*cc | sa*cc+ca*sb*sc | ca*cb | ) |
where ca = cos(a), sa = sin(a), cb = cos(b), sb = sin(b), cc = cos(c), sc = sin(c).
Can have x,y,z in any order, and any angle clockwise or anticlockwise: 48 permutations: all the matrices are different.
~~~~~~~~~~~~~~~~~~~~~~~~