@garagecoder touched the bit on image rotations; another interesting area for affine transformation matrices is colorspace rotations — an easy idea to take in if one is comfortable of thinking of color as forming a three dimensional space with red (neé x), green (neé y) and blue (neé z) axes.
Some recent tutorials which play with this concept of color space rotations:
G’MIC’s math parser serves as a nice laboratory for concocting 3D affine matrices on-the-fly. eye(3)
produces a 3D identity matrix and rot([ax, ay, az],a°)
produces a matrix that rotates points for an angle of a degrees around the axis ax, ay, az (‘°’ is a G’MIC degrees → radians converter; it operates on its left hand parameter, in degrees, and replaces the expression with the radians equivalent). mul(A,B,ccount)
multiplies matrices; ccount
furnishes matrix widths. As always, matrix multiplication is non-communicative. translating and rotating is not the same as rotating and translating. But you knew that. See Vector Calculus.
If you wish to write affine transformation matrices for position vectors written in homogeneous form [x,y,1]
then here is an affine matrix which first translates points 3 units in the x direction, -7 units in the y direction, then rotates the results 43 degrees counterclockwise around the z axis:
$ gmic foo={am=eye(3);am[2]=3;am[5]=-7;mul(rot([0,0,1],43°),am,3)*[0,0,1]} echo $foo
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Set local variable 'foo=6.9680496252950013,-3.073480831146699,1'.
[gmic]-0./ 6.9680496252950013,-3.073480831146699,1
[gmic]-0./ End G'MIC interpreter.
so the origin of the surface at homogeneous point (0,0,1) translates and rotates to ≈ (6.968, -3.073, 1)