An affine transformation is a 2-dimension cartesian transformation applied to both vector and raster data, which can rotate, shift, scale (even applying different factors on each axis) and skew geometries.

An affine transformation is a 2-dimension transformation applied to both vector and raster data, which can rotate, shift, scale (even applying different factors on each axis) and skew geometries.

There are 6 parameters to apply an affine transformation:

a: Scale X 
e: Scale Y
d: Rotation X
b: Rotation Y
c: Translation X
f: Translation Y

These parameters are used in the following formulae:

Xt = X*a + Y*b + c
Yt = X*d + Y*e + f

Where, Xt and Yt are the coordinates of the target point, whereas X and Y are the coordinates of the source point.

Parameters can be calculated from (at least) 3 control points. One ends up solving a system of equations with 6 unknown values and 6 (2 by each target and source coordinates) equations. If more control points are providided, least squares can be applied, and thus residuals and RMSE can be obtained to get an insight on the error associated with the transformation.

In a nutshell, residuals are the difference between transformed source coordinates and target coordinates of control points, whereas the RMSE measures the general deviation of transformed source coordinates with respect to target coordinates of control points.

It is common to take well spread control points and adjust the set of control points (by adding, removing, or moving them ) in order to reduce the RMSE.

More information on: Iliffe, J. and Lott, R. Datums and map projections: For remote sensing, GIS and surveying. Section 4.5. pp.109-117,135-137, 2008.