# Transformation Matrix

### From Math Images

Line 35: | Line 35: | ||

</math> | </math> | ||

===2D Affine Transformations=== | ===2D Affine Transformations=== | ||

- | Affine transformations are represented by transformation matrices that are one higher dimension then the regular transformations. For example a 2d shear | + | Affine transformations are represented by transformation matrices that are one higher dimension then the regular transformations. For example a 2d shear transformation <math>\begin{bmatrix} 1 & k \\ 0 & 1 \end{bmatrix}</math> could be represented by the affine transformation matrix <math>\begin{bmatrix} 1 & k & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}</math>. The transformation performed by the affine transformation matrix can be found in the same manner as a regular transformation matrix with 1 extra dimension added on the matrix and vector or orignal points. Instead of performing the transformation on the points <math>\begin{bmatrix} x \\ y \end{bmatrix}</math> you would perform the transformation on the points <math>\begin{bmatrix} x \\ y \\ 1 \end{bmatrix}. If you calculate the transformation you end up with <math>\begin{bmatrix} x \\ y \\ w \end{bmatrix}</math> where w is a value that you can discard if you are only interested in the (x,y) transfomration. |

====Translation==== | ====Translation==== | ||

Affine transformations are typically used instead because only affine transformations allow translations. The matrix form of x and y translation is: | Affine transformations are typically used instead because only affine transformations allow translations. The matrix form of x and y translation is: |

## Revision as of 16:47, 25 August 2009

A **transformation matrix** is a special matrix that can describe 2d and 3d transformations. Transformations are frequently used in linear algebra and computer graphics, since transformations can be easily represented, combined and computed.

## Contents |

### Computing Transformations

If you have a transformation matrix you can evaluate the transformation that would be performed by multiplying the transformation matrix by the original array of points. For example in 2d suppose you had a trandformation matrix of then the transfomations of the points would be . Similarly, to perform 3d transformation on the points you would use

### Examples in 2D Graphics

In 2D graphics Linear transformations can be represented by 2x2 matrices. Most common transformations such as rotation, scaling, shearing, and reflection are linear transformations and can be represented in the 2x2 matrix. Other affine transformations can be represented in a 3x3 matrix.

#### Rotation

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

Similarly, for a rotation counterclockwise about the origin, the functional form is and and the matrix form is:

#### Scaling

For scaling we have and . The matrix form is:

#### Shearing

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

A shear parallel to the *y* axis has and , which has matrix form:

### 2D Affine Transformations

Affine transformations are represented by transformation matrices that are one higher dimension then the regular transformations. For example a 2d shear transformation could be represented by the affine transformation matrix . The transformation performed by the affine transformation matrix can be found in the same manner as a regular transformation matrix with 1 extra dimension added on the matrix and vector or orignal points. Instead of performing the transformation on the points you would perform the transformation on the points where w is a value that you can discard if you are only interested in the (x,y) transfomration.

#### Translation

Affine transformations are typically used instead because only affine transformations allow translations. The matrix form of x and y translation is:

### Composing transformations

The ability to compose multiple transformation matrix into one matrix is very convenient when you are to calculate many transformations. You can take any number of individual transformations and combine them into a single transformation matrix by multiplying the matrices together. It is important to remember that the order in which you multiply the matrices together is important.