Affine transformations To represent
affine transformations with matrices, we can use
homogeneous coordinates. This means representing a 2-vector (
x,
y) as a 3-vector (
x,
y, 1), and similarly for higher dimensions. Using this system, translation can be expressed with matrix multiplication. The functional form x' = x + t_x; y' = y + t_y becomes: \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}. All ordinary linear transformations are included in the set of affine transformations, and can be described as a simplified form of affine transformations. Therefore, any linear transformation can also be represented by a general transformation matrix. The latter is obtained by expanding the corresponding linear transformation matrix by one row and column, filling the extra space with zeros except for the lower-right corner, which must be set to 1. For example,
the counter-clockwise rotation matrix from above becomes: \begin{bmatrix} \cos \theta & -\sin \theta & 0 \\ \sin \theta & \cos \theta & 0 \\ 0 & 0 & 1 \end{bmatrix} Using transformation matrices containing homogeneous coordinates, translations become linear, and thus can be seamlessly intermixed with all other types of transformations. The reason is that the real plane is mapped to the plane in real projective space, and so translation in real
Euclidean space can be represented as a shear in real projective space. Although a translation is a non-
linear transformation in a 2-D or 3-D Euclidean space described by Cartesian coordinates (i.e. it can't be combined with other transformations while preserving
commutativity and other properties), it
becomes, in a 3-D or 4-D projective space described by homogeneous coordinates, a simple linear transformation (a
shear). More affine transformations can be obtained by
composition of two or more affine transformations. For example, given a translation
T' with vector (t'_x, t'_y), a rotation
R by an angle θ
counter-clockwise, a scaling
S with factors (s_x, s_y) and a translation
T of vector (t_x, t_y), the result
M of '''T'RST''' is: \begin{bmatrix} s_x \cos \theta & - s_y \sin \theta & t_x s_x \cos \theta - t_y s_y \sin \theta + t'_x \\ s_x \sin \theta & s_y \cos \theta & t_x s_x \sin \theta + t_y s_y \cos \theta + t'_y \\ 0 & 0 & 1 \end{bmatrix} When using affine transformations, the homogeneous component of a coordinate vector (normally called
w) will never be altered. One can therefore safely assume that it is always 1 and ignore it. However, this is not true when using perspective projections.
Perspective projection Another type of transformation, of importance in
3D computer graphics, is the
perspective projection. Whereas parallel projections are used to project points onto the image plane along parallel lines, the perspective projection projects points onto the image plane along lines that emanate from a single point, called the center of projection. This means that an object has a smaller projection when it is far away from the center of projection and a larger projection when it is closer (see also
reciprocal function). The simplest perspective projection uses the origin as the center of projection, and the plane at z = 1 as the image plane. The functional form of this transformation is then x' = x / z; y' = y / z. We can express this in
homogeneous coordinates as: \begin{bmatrix} x_c \\ y_c \\ z_c \\ w_c \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}=\begin{bmatrix} x \\ y \\ z \\ z \end{bmatrix} After carrying out the
matrix multiplication, the homogeneous component w_c will be equal to the value of z and the other three will not change. Therefore, to map back into the real plane we must perform the
homogeneous divide or
perspective divide by dividing each component by w_c: \begin{bmatrix} x' \\ y' \\ z' \\ 1 \end{bmatrix} = \frac{1}{w_c} \begin{bmatrix} x_c \\ y_c \\ z_c \\ w_c \end{bmatrix}=\begin{bmatrix} x / z \\ y / z \\ 1 \\ 1 \end{bmatrix} More complicated perspective projections can be composed by combining this one with rotations, scales, translations, and shears to move the image plane and center of projection wherever they are desired. ==See also==