# Transformation Matrix

### From Math Images

(→Rotation) |
|||

Line 1: | Line 1: | ||

A '''transformation matrix''' is a special matrix that can describe transformations. | A '''transformation matrix''' is a special matrix that can describe transformations. | ||

- | Transformation matrices can represent two dimensional transformations as well as three dimensional transformations. Each type of transformation is represented by certain elements in the matrix. | + | Transformation matrices can represent two dimensional transformations as well as three dimensional transformations. Each type of transformation is represented by certain elements in the matrix. |

===Examples in 2D Graphics=== | ===Examples in 2D Graphics=== | ||

Line 15: | Line 15: | ||

:<math> | :<math> | ||

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

+ | </math> | ||

+ | ====Scaling==== | ||

+ | For [[scaling (geometry)|scaling]] (that is, enlarging or shrinking), we have <math>x' = s_x \cdot x</math> and <math>y' = s_y \cdot y</math>. The matrix form is: | ||

+ | |||

+ | :<math> | ||

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

</math> | </math> |

## Revision as of 14:57, 19 August 2009

A **transformation matrix** is a special matrix that can describe transformations.

Transformation matrices can represent two dimensional transformations as well as three dimensional transformations. Each type of transformation is represented by certain elements in the matrix.

### 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 (that is, enlarging or shrinking), we have and . The matrix form is: