Mathematically, an affine transformation translates image coordinates, (x, y), to new coordinates, (x', y'), as follows:
x' = m11x + m12y + m13
y' = m21x + m22y + m23
For a pure rotation by an angle, theta,
m11 = cos(theta)
m11 = - sin(theta)
m21 = sin(theta)
m22 = - cos(theta)
and m13 = m23 = 0.
For a pure translation by (xdelta, ydelta),
m13 = xdelta
m23 = ydelta.
Other combinations provide flips, changes of scale, and even shears.