Transformation Matrix

From Math Images

(Difference between revisions)
Jump to: navigation, search
(Scaling)
Line 21: Line 21:
:<math>
:<math>
\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} s_x & 0 \\ 0 & s_y \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}
\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} s_x & 0 \\ 0 & s_y \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}
 +
</math>
 +
====Shearing====
 +
 +
For [[shear mapping]] (visually similar to slanting), there are two possibilities. For a shear parallel to the ''x'' axis has <math>x' = x + ky</math> and <math>y' = y</math>; the [[shear matrix]], applied to [[column vector]]s, is:
 +
 +
:<math>
 +
\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} 1 & k \\ 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}
 +
</math>
 +
 +
A shear parallel to the ''y'' axis has <math>x' = x</math> and <math>y' = y + kx</math>, which has matrix form:
 +
 +
:<math>
 +
\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ k & 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}
</math>
</math>

Revision as of 16:08, 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.

Contents

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:


\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 counterclockwise about the origin, the functional form is x' = x \cos \theta - y \sin \theta and y' =  x \sin \theta + y \cos \theta 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 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}

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}
Personal tools