2201NSC
Affine Transformations
An affine transformation maps points, straight lines and planes while preserving parallelism — parallel lines stay parallel.
Widely used in geometry, computer graphics and vision to map coordinates while keeping geometric relations. Unlike linear transformations, affine transforms can also translate (shift) the space.
This generalisation makes affine transformations particularly useful for:
Consider a point $\mathbf x=(x,y).$ A transformation $T: \mathbb R^2 \to \mathbb R^2$ of the form
\( \mathbf{T\left( \mathbf x\right)} = \begin{pmatrix} ax + by + e \\ cx + dy + f \end{pmatrix} \)
where $a,b,c,d,e$ and $f$ are real numbers, is called a two-dimensional affine transformation.
\( \mathbf{T\left( \mathbf x\right)} = \begin{pmatrix} ax + by + e \\ cx + dy + f \end{pmatrix} \) For example, if $a,d = 1,$ and $b,c=0,$ then we have a pure translation \[ \mathbf{T\left( \mathbf x\right)} = \begin{pmatrix} x + e \\ y + f \end{pmatrix} \] |
![]() |
\( \mathbf{T\left( \mathbf x\right)} = \begin{pmatrix} ax + by + e \\ cx + dy + f \end{pmatrix} \) If $b,c=0$ and $e,f=0;$ then we have a pure scale \[ \mathbf{T\left( \mathbf x\right)} = \begin{pmatrix} ax \\ dy \end{pmatrix} \] |
![]() |
\( \mathbf{T\left( \mathbf x\right)} = \begin{pmatrix} ax + by + e \\ cx + dy + f \end{pmatrix} \) If $a,d = \cos \theta,$ $b = -\sin \theta,$ $c = \sin \theta,$ and $e,f=0,$ then we have a pure rotation about the origin \[ \small \mathbf{T\left( \mathbf x\right)} = \begin{pmatrix} x\cos\theta -y \sin \theta \\ x\sin \theta + y \cos \theta \end{pmatrix} \] |
![]() |
\( \mathbf{T\left( \mathbf x\right)} = \begin{pmatrix} ax + by + e \\ cx + dy + f \end{pmatrix} \) Finally, if $a,d=1,$ and $e,f=0;$ we have the shear transforms \[ \mathbf{T\left( \mathbf x\right)} = \begin{pmatrix} x+ by \\ y+ cx \end{pmatrix} \] |
![]() |
We know a linear transformation can be written in matrix form
\(T(\mathbf{x}) = \begin{pmatrix} ax + by \\ cx + dy \end{pmatrix} \) \( = \begin{pmatrix} a & b \\ c & d \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix}, \)
Can we do the same with affine transformations? 🤔
No, the problem is the translation❗️
To enable affine transformations, such as translation, to be represented using matrix multiplication, we embed these 2D vectors into 3D space using homogeneous coordinates by appending a third coordinate, conventionally set to 1:
\( \begin{pmatrix} x \\ y \end{pmatrix} \) \( \quad \Rightarrow \quad \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}. \)
This third coordinate is typically called \(w\) to distinguish it from the usual \(z\)-coordinate in 3D geometry.
Therefore, affine transformations can be written as
$\begin{pmatrix} s_x & 0 & 0 \\ 0 & s_y & 0 \\ 0 & 0 & 1 \end{pmatrix}$ | $\begin{pmatrix} \cos \theta & -\sin \theta & 0 \\ \sin \theta & \cos \theta & 0 \\ 0 & 0 & 1 \end{pmatrix}$ |
Scale |
Rotation |
$\begin{pmatrix}1 & h_x & 0 \\ h_y & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$ | $\begin{pmatrix} 1 & 0 & \Delta x \\ 0 & 1 & \Delta y \\ 0 & 0 & 1 \end{pmatrix}$ |
Shear | Translation |
An IFS consists of a finite set of affine transformations \( \{T_1, T_2, \dots, T_n\},\) each of the form:
\( T_i(\mathbf{x}) = A_i \mathbf{x} + \mathbf{t}_i, \)
where \( A_i \) is a \(2 \times 2\) matrix representing a linear transformation (scaling, rotation, or shearing), and \( \mathbf{t}_i \) is a translation vector.
An IFS consists of a finite set of affine transformations \( \{T_1, T_2, \dots, T_n\},\) each of the form:
\( T_i(\mathbf{x}) = A_i \mathbf{x} + \mathbf{t}_i, \)
There are two common approaches for plotting fractals using IFS:
We apply the following affine transformations at each iteration:
\( \begin{aligned} T_1(\mathbf x) &= \begin{pmatrix} 0.5 & 0 & 0\\ 0 & 0.5 & 0 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}, \\[1ex] T_2(\mathbf{x}) &= \begin{pmatrix} 0.5 & 0 & 0 \\ 0 & 0.5 & 100 \\ 0 & 0 & 1\end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}, \\[1ex] T_3(\mathbf{x}) &= \begin{pmatrix} 0.5 & 0 & 100 \\ 0 & 0.5 & 100 \\ 0 & 0 & 1\end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}. \end{aligned} \)
\( \begin{aligned} T_1(\mathbf x) &= \begin{pmatrix} 0.5 & 0 & 0\\ 0 & 0.5 & 0 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}, \end{aligned} \) \( \begin{aligned} T_2(\mathbf{x}) &= \begin{pmatrix} 0.5 & 0 & 0 \\ 0 & 0.5 & 100 \\ 0 & 0 & 1\end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}, \end{aligned} \) \( \begin{aligned} T_3(\mathbf{x}) &= \begin{pmatrix} 0.5 & 0 & 100 \\ 0 & 0.5 & 100 \\ 0 & 0 & 1\end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}. \end{aligned} \) |
|
We apply the following affine transformations, with a given probability for each case:
$ \begin{aligned} T_1(\mathbf{x}) &= \begin{pmatrix} 0 & 0 & 0 \\ 0 & 0.16 & 0 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}, \\[1ex] T_2(\mathbf{x}) &= \begin{pmatrix} 0.85 & 0.04 & 0 \\ -0.04 & 0.85 & 1.6 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}, \\[1ex] T_3(\mathbf{x}) &= \begin{pmatrix} 0.2 & -0.26 & 0 \\ 0.23 & 0.22 & 1.6 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}, \\[1ex] T_4(\mathbf{x}) &= \begin{pmatrix} -0.15 & 0.28 & 0 \\ 0.26 & 0.24 & 0.44 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix}. \end{aligned} $ |
|
IFS values for a fern
T | a | b | c | d | e | f | p |
---|---|---|---|---|---|---|---|
1 | 0 | 0 | 0 | 0.16 | 0 | 0 | 0.01 |
2 | 0.85 | 0.04 | -0.04 | 0.85 | 0 | 1.6 | 0.85 |
3 | 0.2 | -0.26 | 0.23 | 0.22 | 0 | 1.6 | 0.07 |
4 | -0.15 | 0.28 | 0.26 | 0.24 | 0 | 0.44 | 0.07 |
$ \begin{aligned} T_1(\mathbf{x}) &= \begin{pmatrix} 0 & 0 & 0 \\ 0 & 0.16 & 0 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix} \end{aligned} \mapsto 0.01 $ $ \begin{aligned} T_2(\mathbf{x}) &= \begin{pmatrix} 0.85 & 0.04 & 0 \\ -0.04 & 0.85 & 1.6 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix} \end{aligned} \mapsto 0.85 $ $ \begin{aligned} T_3(\mathbf{x}) &= \begin{pmatrix} 0.2 & -0.26 & 0 \\ 0.23 & 0.22 & 1.6 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix} \end{aligned} \mapsto 0.07 $ $ \begin{aligned} T_4(\mathbf{x}) &= \begin{pmatrix} -0.15 & 0.28 & 0 \\ 0.26 & 0.24 & 0.44 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \\ 1 \end{pmatrix} \end{aligned} \mapsto 0.07 $ |
|