# Affine transformations

An **affine transformation** is a type of geometric transformation which preserves collinearity (if a collection of points sits on a line before the transformation, they all sit on a line afterwards) and the ratios of distances between points on a line. Types of affine transformations include translation (moving a figure), scaling (increasing or decreasing the size of a figure), and rotation (turning a figure about a point).

Note that affine transformations can be done \(\mathbb{R}^n\), for \(n\geq 1\), although some of the transformations do not make sense for \(n=1\). Matrix algebra will be used to unify the presentation. To get an unique affine transformation matrix, one more point is needed than the \(n\) of the \(\mathbb{R}^n\) space. It also is assumed that the points do not share a common \(\mathbb{R}^{n-1}\) space. For example, in \(\mathbb{R}^2\) space, 3 points are required and they must not all in in the same \(\mathbb{R}^1\) space, that is, must not be collinear.

The examples and computations will be in \(\mathbb{R}^2\). Hopefully the extension to \(n\gt 2\) will be obvious.

#### Contents

## Visual examples of affine transformations

In each example, the *before* is red and solid and the *after* is blue and dashed. The corners of the example triangle will be labeled as follows: the first will have a small disk, the second will have a small quadrilateral and the third vertex will have a small five-sided object. All of these labels will be in translucent gray. The original triangle will be (0,0), (1,0) and (0,1), in each example.

## Translation

Right by \(\frac12\) and up by \(\frac13\)

## Scaling

By \(\frac12\) vertically. By definition, scaling is in one direction only. Note, multiple scaling on more than axis is permissible and in on all axes, becomes a magnification or homothety..

## Reflection

A reflection about an infinite line passing through \((0,1)\) with a slope of \(-\frac12\):

## Rotation

A rotation about the origin through an angle of \(\frac23\pi\) radians:

## Shearing or shear

A shearing about the origin through an angle of \(\text{arctan}(\frac12)\) radians:

## Augmented matrices and homogeneous coordinates

Affine transformations become linear transformations in one dimension higher. By assigning a point a next coordinate of \(1\), e.g., \((x,y)\) becomes \((x,y,1)\), these are called *homogeneous coordinates.* Since linear transformations are represented easily by matrices, the corresponding entity is an augmented matrix, where the \(a\)s provide all transformation except translation and those are represented by the \(b\)s.
\[\bm{a}=
\left(
\begin{array}{ccc}
a_{1,1} & a_{1,2} & b_1 \\
a_{2,1} & a_{2,2} & b_2 \\
0 & 0 & 1 \\
\end{array}
\right)
\]

## Finding an affine transformation and its reverse

The example sets of points are the original set and the final set.

The original set are \((-2,2)\), \((0,1)\) and \((2,0)\),. In a \(3\times 3\) matrix, that becomes: \[\bm{o}= \left( \begin{array}{ccc} -2 & 0 & 2 \\ 2 & -1 & 0 \\ 1 & 1 & 1 \\ \end{array} \right) \]

The desired final set is \((1,0)\), \((0,\frac{\sqrt{3}}{2})\) and \((0,\frac{\sqrt{3}}{2})\). In a \(3\times 3\) matrix, that becomes: \[\bm{n} \left( \begin{array}{ccc} 1 & -\frac{1}{2} & -\frac{1}{2} \\ 0 & \frac{\sqrt{3}}{2} & -\frac{\sqrt{3}}{2} \\ 1 & 1 & 1 \\ \end{array} \right) \]

Therefore, the affine transformation matrix is the \(\bm{a}\) of \(\bm{a}.\bm{o}=\bm{n}\).

That can be solved for by \(\bm{a}=\bm{n}.\bm{o}^{-1}\). Note the following, because matrix multiplication is **not** commutative, i. e., the multiplicands may not swap sides, the inverse of \(\bm{o}\) has to go to the side of \(\bm{n}\) that \(\bm{o}\) was on on \(\bm{a}\) previously. Since, in this article, column vectors and left side matrix multiplication is being used by convention, that means that
\(\bm{o}^{-1}\) would go to the **right** side of \(\bm{n}\). Also, note that if \(\bm{o}\) will not invert, that means the original points are in a common subspace, e.g., are collinear in the case of 2D, coplanar in the case of 3D, etc.

\[\bm{n}.\bm{o}^{-1}= \left( \begin{array}{ccc} -\frac{3}{16} & \frac{3}{8} & -\frac{1}{8} \\ -\frac{1}{16} \left(5 \sqrt{3}\right) & -\frac{1}{8} \left(3 \sqrt{3}\right) & \frac{\sqrt{3}}{8} \\ 0 & 0 & 1 \\ \end{array} \right) \]

The reverse transformation is matrix inverse of the forward transformation: \[ \left( \begin{array}{ccc} -2 & -\frac{2}{\sqrt{3}} & 0 \\ \frac{5}{3} & -\frac{1}{\sqrt{3}} & \frac{1}{3} \\ 0 & 0 & 1 \\ \end{array} \right) \]

## Movie of smooth transition between after and before affine transformation

Each frame of the movie is \(\frac{1}{180}\) of the total affine transformation from all to none and back again.

## See also

**Cite as:**Affine transformations.

*Brilliant.org*. Retrieved from https://brilliant.org/wiki/affine-transformations/