6.4. Translation#

In the previous section we looked at how to rotate, reflect and scale a vector. To complete the movement of vectors in \(\mathbb{R}^2\) we need to be able to translate vectors.

Definition 6.9 (Translation)

The translation of a position vector \(\vec{u} \in \mathbb{R}^n\) by a translation vector \(\vec{t} \in \mathbb{R}^n\) is the linear transformation \(T(\vec{t}): \vec{u} \mapsto \vec{u} + \vec{t}\).

../_images/6_translation.svg

Fig. 6.9 The translation of the vector \(\vec{u}\) by the vector \(\vec{t}\) in \(\mathbb{R}^2\).#

The problem we have here is what is the matrix representation of translation, i.e., in \(\mathbb{R}^2\) what is the matrix \(T\) that satisfies

\[\begin{split} T(\vec{t}) \cdot \begin{pmatrix} u_x \\ u_y \end{pmatrix} = \begin{pmatrix} u_x + t_x \\ u_y + t_y \end{pmatrix}. \end{split}\]

A matrix \(T(\vec{t})\) does not exist which is independent of \(u_x\) and \(u_y\) so we can use a trick which makes use of homogeneous co-ordinates. A point is typically represented by Cartesian coordinates as \((x, y)\). Homogeneous coordinates extend this representation by introducing an additional coordinate, denoted as \(w\), to represent the point in homogeneous coordinates as \((wx, wy, w)\). To convert homogeneous co-ordinates to Cartesian co-ordinates we divide throughout by the additional co-ordinate \(w\), i.e.,

\[\underbrace{(wx, wy, w)}_{\textsf{homogeneous}} \mapsto \underbrace{\left( \frac{x}{w}, \frac{y}{w} \right)}_{\textsf{Cartesian}}.\]

Definition 6.10 (Homogeneous co-ordinates)

The homogeneous co-ordinates of a point \(\vec{u}\) in \(\mathbb{R}^n\) expressed using the Cartesian co-ordinates is the \((n+1)\)-tuple \((w u_1, w u_2, \ldots, w u_n, w)\) where \(w \in \mathbb{R}\backslash \{0\}\).

We often set \(w=1\) when using homogeneous co-ordinates since this makes mapping from Cartesian co-ordinates easy, i.e.,

\[ (x, y, 1) \mapsto (x, y).\]

If we express a point in \(\mathbb{R}^2\) with Cartesian co-ordinates \((u_1, u_2)\) using the homogeneous co-ordinates \((u_x, u_y, 1)\) then we can find a \(3 \times 3\) translation matrix \(T(\vec{t})\) that satisfies

\[\begin{split} T(\vec{t}) \cdot \begin{pmatrix} u_x \\ u_y \\ 1 \end{pmatrix} = \begin{pmatrix} u_x + t_x \\ u_y + t_y \\ 1 \end{pmatrix}.\end{split}\]

so

\[\begin{split} \begin{pmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} u_x \\ u_y \\ 1 \end{pmatrix} = \begin{pmatrix} u_x + t_x \\ u_y + t_y \\ 1 \end{pmatrix} \end{split}\]

Theorem 6.6 (Translation in \(\mathbb{R}^2\))

The translation of the vector \(\vec{u} \in \mathbb{R}^2\) by the translation vector \(\vec{t} \in \mathbb{R}^2\) is

\[\begin{split} T(\vec{t}) : \begin{pmatrix} u_x \\ u_y \end{pmatrix} \mapsto \begin{pmatrix} u_x + t_x \\ u_y + t_y \end{pmatrix}. \end{split}\]

If \(\vec{u}\) is expressed using homogeneous co-ordinates then the transformation matrix for translation is

(6.12)#\[\begin{split} T(\vec{t}) = \begin{pmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{pmatrix}. \end{split}\]

The inverse translation is to translate by \(-\vec{t}\), therefore

\[\begin{split} T^{-1}(-\vec{t}) = \begin{pmatrix} 1 & 0 & -t_x \\ 0 & 1 & -t_y \\ 0 & 0 & 1 \end{pmatrix}. \end{split}\]

Example 6.10

Translate the point with position vector \(\vec{u} = (2, 3)^\mathsf{T}\) by the vector \(\vec{t} = (3, -1)^\mathsf{T}\).

Solution

Expressing the position vector \(\vec{u} = \begin{pmatrix} 2 \\ 3 \end{pmatrix}\) using homogeneous co-ordinates we have \(\vec{u} = \begin{pmatrix} 2 \\ 3 \\ 1 \end{pmatrix}\).

The translation matrix is

\[\begin{split} \begin{align*} T\begin{pmatrix} 3 \\ -1 \end{pmatrix} = \begin{pmatrix} 1 & 0 & 3 \\ 0 & 1 & -1 \\ 0 & 0 & 1 \end{pmatrix}. \end{align*} \end{split}\]

Applying the transformation to \(\vec{u}\)

\[\begin{split} \begin{align*} T(3, -1) \cdot \begin{pmatrix} 2 \\ 3 \\ 1 \end{pmatrix} = \begin{pmatrix} 1 & 0 & 3 \\ 0 & 1 & -1 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} 2 \\ 3 \\ 1 \end{pmatrix} = \begin{pmatrix} 5 \\ 2 \\ 1 \end{pmatrix}. \end{align*} \end{split}\]
../_images/6_translation_example.svg

6.4.1. Combining rotation, reflection, scaling and translation transformation#

If we want to combine translation with rotation, reflection and scaling transformations in \(\mathbb{R}^2\) then we need all of the transformation matrices to be \(3 \times 3\) matrices. This is easily done by adding the third row and column of the identity matrix to \(Rot(\theta)\), \(Ref(\theta)\) and \(S(\vec{s})\) from equations (6.8), (6.10) and (6.11) , i.e.,

\[\begin{split} \begin{align*} Rot(\theta) &= \begin{pmatrix} \cos(\theta) & \sin(\theta) & 0 \\ -\sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 1 \end{pmatrix}, \\ Ref(\theta) &= \begin{pmatrix} \cos(2\theta) & \sin(2\theta) & 0 \\ \sin(2\theta) & -\cos(2\theta) & 0 \\ 0 & 0 & 1 \end{pmatrix}, \\ S(\vec{s}) &= \begin{pmatrix} s_1 & 0 & 0 \\ 0 & s_2 & 0 \\ 0 & 0 & 1 \end{pmatrix}. \end{align*} \end{split}\]

6.4.2. Applying a transformation to multiple vectors#

To apply transformation to multiple vectors in \(\vec{u}_1, \vec{u}_2, \ldots, \vec{u}_m \in \mathbb{R}^2\) which are expressed using homogeneous co-ordinates we form an \(3 \times m\) matrix \(U\) where each of these vectors form the columns of \(U\), i.e.,

\[\begin{split} U = \begin{pmatrix} \uparrow & \uparrow & & \uparrow \\ \vec{u}_1 & \vec{u}_2 & \cdots & \vec{u}_m \\ \downarrow & \downarrow & & \downarrow \end{pmatrix}. \end{split}\]

Given an \(3 \times 3\) transformation matrix \(A\) we can apply this transformation to all of the vectors \(\vec{u}_1, \vec{u}_2, \ldots, \vec{u}_m\) using \(V = A \cdot U.\)

Example 6.11

An isosceles triangle has the vertices with co-ordinates \((-1,-1)\), \((1,-1)\) and \((0,2)\). The triangle is transformed using the following transformations:

  • Scaled by a factor of 2 in both directions

  • Rotated by \(\pi/4\) anti-clockwise about the origin

  • Translated by the vector \(\vec{t} = (6,4)^\mathsf{T}\)

Calculate the co-ordinates of the triangle after each of these transformations has been applied and determine a transformation matrix that performs all three transformations at the same time.

Solution

Using homogeneous co-ordinates the vertices have position vectors \(\begin{pmatrix} -1 \\ -1 \\ 1 \end{pmatrix}\), \(\begin{pmatrix} 1 \\ -1 \\ 1 \end{pmatrix}\) and \(\begin{pmatrix} 0 \\ 2 \\ 1 \end{pmatrix}\). We can combine into a single matrix

\[\begin{split} U = \begin{pmatrix} -1 & 1 & 0 \\ -1 & -1 & 2 \\ 1 & 1 & 1 \end{pmatrix}. \end{split}\]

Since we are scaling by a factor of 2 in both directions then the scaling vector is \(\vec{s} = \begin{pmatrix} 2 \\ 2 \end{pmatrix}\) so the scaling matrix is

\[\begin{split} \begin{align*} S\begin{pmatrix} 2 \\ 2 \end{pmatrix} = \begin{pmatrix} 2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 1 \end{pmatrix}. \end{align*} \end{split}\]

Applying the scaling matrix to the homogeneous co-ordinates

\[\begin{split} \begin{align*} V &= S\begin{pmatrix} 2 \\ 2 \end{pmatrix} \cdot U \\ &= \begin{pmatrix} 2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} -1 & 1 & 0 \\ -1 & -1 & 2 \\ 1 & 1 & 1 \end{pmatrix}\\ &= \begin{pmatrix} -2 & 2 & 0 \\ -2 & -2 & 4 \\ 1 & 1 & 1 \end{pmatrix}. \end{align*} \end{split}\]
../_images/6_rotation_scaling_and_translation_example_1.svg

We want to rotate by an angle of \(\frac{\pi}{4}\) so the rotation matrix is

\[\begin{split} \begin{align*} Rot\left( \frac{\pi}{4} \right) &= \begin{pmatrix} \cos(\pi/4) & -\sin(\pi/4) & 0 \\ \sin(\pi/4) & \cos(\pi/4) & 0 \\ 0 & 0 & 1 \end{pmatrix} = \begin{pmatrix} \sqrt{2}/2 & -\sqrt{2}/2 & 0 \\ \sqrt{2}/2 & \sqrt{2}/2 & 0 \\ 0 & 0 & 1 \end{pmatrix}. \end{align*} \end{split}\]

Applying the rotating matrix to \(W\)

\[\begin{split} \begin{align*} W &= Rot\left(\frac{\pi}{4}\right) \cdot V \\ &= \begin{pmatrix} \sqrt{2}/2 & -\sqrt{2}/2 & 0 \\ \sqrt{2}/2 & \sqrt{2}/2 & 0 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} -2 & 2 & 0 \\ -2 & -2 & 4 \\ 1 & 1 & 1 \end{pmatrix} \\ &= \begin{pmatrix} 0 & 2 \sqrt{2} & -2\sqrt{2} \\ -2\sqrt{2} & 0 & 2\sqrt{2} \\ 1 & 1 & 1 \end{pmatrix} \\ &\approx \begin{pmatrix} 0 & 2.8482 & -2.8482 \\ -2.8482 & 0 & 2.8482 \\ 1 & 1 & 1 \end{pmatrix}. \end{align*} \end{split}\]
../_images/6_rotation_scaling_and_translation_example_2.svg

Finally we need to translate by the translation vector \(\vec{t} = \begin{pmatrix} 6 \\ 4 \end{pmatrix}\) so the translation matrix is

\[\begin{split} T\begin{pmatrix} 6 \\ 4 \end{pmatrix} = \begin{pmatrix} 1 & 0 & 6 \\ 0 & 1 & 4 \\ 0 & 0 & 1 \end{pmatrix}. \end{split}\]

Applying the translation matrix to \(W\)

\[\begin{split} \begin{align*} X &= T\begin{pmatrix} 6 \\ 4 \end{pmatrix} \cdot W \\ &= \begin{pmatrix} 1 & 0 & 6 \\ 0 & 1 & 4 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} 0 & 2 \sqrt{2} & -2\sqrt{2} \\ -2\sqrt{2} & 0 & 2\sqrt{2} \\ 1 & 1 & 1 \end{pmatrix} \\ &= \begin{pmatrix} 6 & 6 + 2\sqrt{2} & 6 - 2\sqrt{2} \\ 4 - 2\sqrt{2} & 4 & 4 + 2\sqrt{2} \\ 1 & 1 & 1 \end{pmatrix} \\ &\approx \begin{pmatrix} 6 & 8.8284 & 3.1716 \\ 1.1716 & 4 & 6.8284 \\ 1 & 1 & 1 \end{pmatrix}. \end{align*} \end{split}\]
../_images/6_rotation_scaling_and_translation_example_3.svg

The single transformation matrix that performs the three transformations at the same time is

\[\begin{split} \begin{align*} A &= T\begin{pmatrix} 6 \\ 4 \end{pmatrix} \cdot Rot(\pi/4) \cdot S\begin{pmatrix} 2 \\ 2 \end{pmatrix} \\ &= \begin{pmatrix} 0 & 2 \sqrt{2} & -2\sqrt{2} \\ -2\sqrt{2} & 0 & 2\sqrt{2} \\ 1 & 1 & 1 \end{pmatrix} \begin{pmatrix} \sqrt{2}/2 & -\sqrt{2}/2 & 0 \\ \sqrt{2}/2 & \sqrt{2}/2 & 0 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} 2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 1 \end{pmatrix} \\ &= \begin{pmatrix} \sqrt{2} & -\sqrt{2} & 6 \\ \sqrt{2} & \sqrt{2} & 4 \\ 0 & 0 & 1 \end{pmatrix} \approx \begin{pmatrix} 1.4142 & -1.4142 & 6 \\ 1.4142 & 1.4142 & 4 \\ 0 & 0 & 1 \end{pmatrix}. \end{align*} \end{split}\]

Checking that \(A \cdot V = X\):

\[\begin{split} \begin{align*} A \cdot V &= \begin{pmatrix} \sqrt{2} & -\sqrt{2} & 6 \\ \sqrt{2} & \sqrt{2} & 4 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} -1 & 1 & 0 \\ -1 & -1 & 2 \\ 1 & 1 & 1 \end{pmatrix} \\ &= \begin{pmatrix} 6 & 6 + 2\sqrt{2} & 6 - 2\sqrt{2} \\ 4 - 2\sqrt{2} & 4 & 4 + 2\sqrt{2} \\ 1 & 1 & 1 \end{pmatrix} = X \quad \checkmark \end{align*} \end{split}\]