Transformation matrix


Transformation matrix

In linear algebra, linear transformations can be represented by matrices. If T is a linear transformation mapping Rn to Rm and x is a column vector with n entries, then

T( \vec x ) = \mathbf{A} \vec x

for some m×n matrix A, called the transformation matrix of T. There is an alternative expression of transformation matrices involving row vectors that is preferred by some authors.

Contents

Uses

Matrices allow arbitrary linear transformations to be represented in a consistent format, suitable for computation. This also allows transformations to be concatenated easily (by multiplying their matrices).

Linear transformations are not the only ones that can be represented by matrices. Some transformations that are non-linear on a n-dimensional Euclidean space Rn, can be represented as linear transformations on the n+1-dimensional space Rn+1. These include both affine transformations (such as translation) and projective transformations. For this reason, 4x4 transformation matrices are widely used in 3D computer graphics. These n+1-dimensional transformation matrices are called, depending on their application, affine transformation matrices, projective transformation matrices, or more generally non-linear transformation matrices. With respect to a n-dimensional matrix, a n+1-dimensional matrix can be described as an augmented matrix.

Finding the matrix of a transformation

If one has a linear transformation T(x) in functional form, it is easy to determine the transformation matrix A by simply transforming each of the vectors of the standard basis by T and then inserting the results into the columns of a matrix. In other words,

\mathbf{A} = \begin{bmatrix} T( \vec e_1 ) & T( \vec e_2 ) & \cdots & T( \vec e_n ) \end{bmatrix}

For example, the function T(x) = 5x is a linear transformation. Applying the above process (suppose that n = 2 in this case) reveals that

T( \vec{x} ) = 5 \vec{x} = 5 \mathbf{I} \vec{x} = \begin{bmatrix} 5 && 0 \\ 0 && 5 \end{bmatrix} \vec{x}

Examples in 2D graphics

Most common geometric transformations that keep the origin fixed are linear, including rotation, scaling, shearing, reflection, and orthogonal projection; if an affine transformation is not a pure translation it keeps some point fixed, and that point can be chosen as origin to make the transformation linear. In two dimensions, linear transformations can be represented using a 2×2 transformation matrix.

Rotation

For rotation by an angle θ counter clockwise about the origin, the functional form is x' = xcos θ − ysin θ and y' = xsin θ + ycos θ. Written in matrix form, this becomes:


\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} \cos \theta &  -\sin\theta \\ \sin \theta & \cos \theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}

Similarly, for a rotation clockwise about the origin, the functional form is x' = xcos θ + ysin θ and y' = − xsin θ + ycos θ and the matrix form is:


\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} \cos \theta &  \sin\theta \\ -\sin \theta & \cos \theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}

Scaling

For scaling (that is, enlarging or shrinking), we have x' = s_x \cdot x and y' = s_y \cdot y. The matrix form is:


\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} s_x & 0 \\ 0 & s_y \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}

When \ s_x s_y = 1, then the matrix is a squeeze mapping and preserves areas in the plane.

Shearing

For shear mapping (visually similar to slanting), there are two possibilities. For a shear parallel to the x axis has x' = x + ky and y' = y; the shear matrix, applied to column vectors, is:


\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} 1 & k \\ 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}

A shear parallel to the y axis has x' = x and y' = y + kx, which has matrix form:


\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ k & 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}

Reflection

To reflect a vector about a line that goes through the origin, let \scriptstyle \vec{l} = (l_x, l_y) be a vector in the direction of the line:


\mathbf{A} = \frac{1}{\lVert\vec{l}\rVert^2} \begin{bmatrix} l_x^2 - l_y^2 & 2 l_x l_y \\ 2 l_x l_y & l_y^2 - l_x^2 \end{bmatrix}

To reflect a point through a plane ax + by + cz = 0 (which goes through the origin), one can use \mathbf{A} = \mathbf{I}-2\mathbf{NN}^T , where \mathbf{I} is the 3x3 identity matrix and \mathbf{N} is the three-dimensional unit vector for the surface normal of the plane. If the L2 norm of a,b, and c is unity, the transformation matrix can be expressed as:


\mathbf{A} = \begin{bmatrix} 1 - 2 a^2  & - 2 a b & - 2 a c \\ - 2 a b  & 1 - 2 b^2 & - 2 b c  \\ - 2 a c & - 2 b c & 1 - 2c^2 \end{bmatrix}

Note that these are particular cases of a Householder reflection in two and three dimensions. A reflection about a line or plane that does not go through the origin is not a linear transformation; it is an affine transformation.

Orthogonal projection

To project a vector orthogonally onto a line that goes through the origin, let \scriptstyle \vec{u} \,=\, (u_x, u_y) be a vector in the direction of the line. Then use the transformation matrix:


\mathbf{A} = \frac{1}{\lVert\vec{u}\rVert^2} \begin{bmatrix} u_x^2 & u_x u_y \\ u_x u_y & u_y^2 \end{bmatrix}

As with reflections, the orthogonal projection onto a line that does not pass through the origin is an affine, not linear, transformation.

Parallel projections are also linear transformations and can be represented simply by a matrix. However, perspective projections are not, and to represent these with a matrix, homogeneous coordinates must be used.

Composing and inverting transformations

One of the main motivations for using matrices to represent linear transformations is that transformations can then be easily composed (combined) and inverted.

Composition is accomplished by matrix multiplication. If A and B are the matrices of two linear transformations, then the effect of applying first A and then B to a vector x is given by:

\mathbf{B}(\mathbf{A} \vec{x} ) = (\mathbf{BA}) \vec{x}

In other words, the matrix of the combined transformation A followed by B is simply the product of the individual matrices. Note that the multiplication is done in the opposite order from the English sentence: the matrix of "A followed by B" is BA, not AB.

A consequence of the ability to compose transformations by multiplying their matrices is that transformations can also be inverted by simply inverting their matrices. So, A-1 represents the transformation that "undoes" A.

Other kinds of transformations

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 + tx; y' = y + ty 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. Hence, any linear transformation can be also 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 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 can be seamlessly intermixed with all other types of transformations. The reason is that the real plane is mapped to the w = 1 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, it becomes, in a 3-D or 4-D projective space described by homogeneous coordinates, a simple linear transformation (a shear).

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.

The simplest perspective projection uses the origin as the center of projection, and 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 wc will, in general, not be equal to 1. Therefore, to map back into the real plane we must perform the homogeneous divide or perspective divide by dividing each component by wc:


\begin{bmatrix} x' \\ y' \\ z' \end{bmatrix} = \frac{1}{w_c} \begin{bmatrix} x_c \\ y_c \\ z_c \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

External links


Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Matrix - получить на Академике рабочий купон на скидку Летуаль или выгодно matrix купить с бесплатной доставкой на распродаже в Летуаль

  • transformation matrix — transformacijos matrica statusas T sritis automatika atitikmenys: angl. transformation matrix vok. Transformationsmatrix, f rus. матрица преобразования, f pranc. matrice de transformation, f …   Automatikos terminų žodynas

  • transformation matrix — transformacijos matrica statusas T sritis fizika atitikmenys: angl. transformation matrix vok. Transformationsmatrix, f rus. матрица преобразования, f pranc. matrice de transformation, f …   Fizikos terminų žodynas

  • Matrix (mathematics) — Specific elements of a matrix are often denoted by a variable with two subscripts. For instance, a2,1 represents the element at the second row and first column of a matrix A. In mathematics, a matrix (plural matrices, or less commonly matrixes)… …   Wikipedia

  • Transformation (function) — In mathematics, a transformation could be any function mapping a set X on to another set or on to itself. However, often the set X has some additional algebraic or geometric structure and the term transformation refers to a function from X to… …   Wikipedia

  • Transformation (geometry) — In mathematics, a transformation could be any function from a set X to itself. However, often the set X has some additional algebraic or geometric structure and the term transformation refers to a function from X to itself which preserves this… …   Wikipedia

  • Transformation de lorentz — Cet article présente les transformations de Lorentz sous un aspect technique. Le lecteur désireux d obtenir des informations physiques plus générales à ce sujet pourra se référer à l article relativité restreinte. Les transformations de Lorentz… …   Wikipédia en Français

  • Transformation grammaticale (Generativisme) — Transformation grammaticale Pour les articles homonymes, voir Transformation. La transformation grammaticale est une notion théorique dans le domaine de la linguistique descriptive. Sommaire 1 Présentation 2 Théori …   Wikipédia en Français

  • Transformation grammaticale (Générativisme) — Transformation grammaticale Pour les articles homonymes, voir Transformation. La transformation grammaticale est une notion théorique dans le domaine de la linguistique descriptive. Sommaire 1 Présentation 2 Théori …   Wikipédia en Français

  • Transformation grammaticale (générativisme) — Transformation grammaticale Pour les articles homonymes, voir Transformation. La transformation grammaticale est une notion théorique dans le domaine de la linguistique descriptive. Sommaire 1 Présentation 2 Théori …   Wikipédia en Français

  • Matrix of Leadership — Plot element from the Transformers franchise Publisher Marvel Comics (introduction only) First appearance Transformers issue 10 (November 1985) Created by Bob Budiansky …   Wikipedia