Transformation Matrix

In mathematics, in particular in linear algebra and geometry, a linear transformation can be represented by matrix multiplication. If A is a matrix and x a column vector,
T(x) = Ax
is called multiplication by A. The linear transformation T(x,y) = (x,y) would be represented by the identity matrix. T(x) = Ix = x, and would be known as the identity operator. It is very often useful to represent a transformation by a matrix, this reduces the calculation time and enables the combining of transformations.

Example: 2D graphics

In two dimensions, linear transformations can be represented using a 3×3 transformation matrix. Such transformations are useful, for example, in 2D computer graphics where translation corresponds to scrolling and scaling corresponds to zooming.

Translation

For translation (that is, moving all points a fixed amount horizontally and/or vertically), we have x' = x + dx\, and y' = y + dy\, for all points (x,y). The corresponding transformation matrix calculation is:
\begin{vmatrix} x' & y' & 1 \end{vmatrix} = \begin{vmatrix} x & y & 1 \end{vmatrix} \times \begin{vmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ dx & dy & 1 \end{vmatrix}

Scaling

For scaling (that is, enlarging or shrinking), we have x' = x \cdot zx and y' = y \cdot zy, and the matrix form is:
\begin{vmatrix} x' & y' & 1 \end{vmatrix} = \begin{vmatrix} x & y & 1 \end{vmatrix} \times \begin{vmatrix} zx & 0 & 0 \\ 0 & zy & 0 \\ 0 & 0 & 1 \end{vmatrix}

Shearing

For shearing (for example, slanting a figure), we have x' = x + sx \cdot y and y' = y + sy \cdot x, and the matrix form is:
\begin{vmatrix} x' & y' & 1 \end{vmatrix} = \begin{vmatrix} x & y & 1 \end{vmatrix} \times \begin{vmatrix} 1 && sy && 0 \\ sx && 1 && 0 \\ 0 && 0 && 1 \end{vmatrix}

Rotation

For rotation by an angle A counterclockwise about the origin, we have x' = x \cos A - y \sin A\, and y' = x \sin A + y \cos A\,, and the matrix form is:
\begin{vmatrix} x' & y' & 1 \end{vmatrix} = \begin{vmatrix} x & y & 1 \end{vmatrix} \times \begin{vmatrix} \cos A & \sin A & 0 \\ -\sin A & \cos A & 0 \\ 0 & 0 & 1 \end{vmatrix}

Reflection

For reflection (that is, a mirror image) about one or both axes, simply use a scale factor of -1 for zx and/or zy (see Scaling above).

Composite transformations

It is important to note that transformation matricies can be combined using ordinary matrix multiplication. For example, if we want to both translate and scale all points, we could apply the two appropriate matrices from above to each point; but a better way would be to multiply the two matrices to get a new, combined transformation matrix and then apply that single new matrix to each point. Multiplying transformation matrices results in a composition of the transformations. In general, matrix multiplication is not commutative, so the order of multiplication is important. Transforming with the product matrix A × B is equivalent to transforming with B first and then A. An important special-case composite transformation represents translation by (dx,dy) followed by scaling by (zx,zy). The matrix for this is simply:
\begin{vmatrix} zx & 0 & 0 \\ 0 & zy & 0 \\ dx & dy & 1 \end{vmatrix}

Calculating coordinates

Once a transformation matrix (call it T) has been calculated, (x',y') for each point (x,y) can be calculated using the rules for matrix multiplication. Note that all transformation matricies considered here have the third column equal to \begin{vmatrix} 0 \\ 0 \\ 1 \end{vmatrix} .
  • x' = x \cdot T_{11} + y \cdot T_{21} + T_{31}
  • y' = x \cdot T_{12} + y \cdot T_{22} + T_{32}

Reverse transformations

It is possible to perform a reverse transformation by calculating the inverse of the matrix. This would be useful, for example, in 2D computer graphics to interpret a mouse-down event. To calculate the inverse U of T in the 2D case:
  • Calculate the determinant d = T_{22} \cdot T_{11} - T_{21} \cdot T_{12}
  • U_{11} = T_{22} / d \,
  • U_{12} = - T_{12} / d \,
  • U_{13} = 0 \,
  • U_{21} = - T_{21} / d \,
  • U_{22} = T_{11} / d \,
  • U_{23} = 0 \,
  • U_{31} = ( T_{32} \cdot T_{21} - T_{31} \cdot T_{22} ) / d \,
  • U_{32} = ( - T_{32} \cdot T_{11} + T_{31} \cdot T_{12} ) / d \,
  • U_{33} = 1 \,
One can then calculate
\begin{vmatrix} x && y && 1 \end{vmatrix} = \begin{vmatrix} x' && y' && 1 \end{vmatrix} \times U \, using formulae analogous to the above (see Calculating coordinates).

Generalization

Generalization of these methods to three dimensions (using a 4×4 matrix) and higher is possible.

 

<< PreviousWord BrowserNext >>
wwe undisputed championship
frankie poullain
charley fox
hair analysis
dreamcatcher (native american)
contraband (album)
athol fugard
fictional currency
sleepwalker (comics)
mount baw baw
fractional coloring
catherine gore
almond milk
the vanguard group
lingfield park
larry w. esposito
2000 european football championship (qualifying)
elective dictatorship
jack wisdom
cinnabar moth
south central railway
belle's good cide
dillie keane
awake (disambiguation)
goose goslin
w12
charles ruggles
rotation operator
russell davies
powers (comics)
anbal acevedo vil
triple crown (rugby union)
richard robinson
edward douglass white
ready meal
mega man zero
montefeltro
lingfield, surrey
harry kellar
mega man x
mazikeen
chatfield hollow state park
leopold auenbrugger
royal pharmaceutical society