Linear Transformations#

To create a virtual environment we need to be able to scale, rotate and move objects in the space. To do this we make use of linear transformations.

Definition#

Definition 15 (Linear transformation)

If \(V\) and \(W\) are two vector spaces over the same field \(F\) then by a linear transformation (or linear mapping) is a mapping \(T: V \to W\) that for any two vectors \(\mathbf{u}, \mathbf{v} \in V\) and any scalar \(\alpha \in F\) the following conditions hold

  • addition operation: \(T(\mathbf{u} + \mathbf{v}) = T(\mathbf{u}) + T(\mathbf{v})\);

  • scalar multiplication: \(T(\alpha \mathbf{u}) = \alpha T(\mathbf{u})\).

The result of applying a linear transformation to an object is known as the image.

To show whether a transformation is a linear transformation can combine both conditions from Definition 15 to show that

(19)#\[T(\mathbf{u} + \alpha \mathbf{v}) = T(\mathbf{u}) + \alpha T(\mathbf{v}).\]

Transformation matrices#

For convenience we tend to use matrices to represent linear transformations. Let \(T: V \to W\) be a linear transformation from the vector spaces \(V\) to \(W\). If \(\{\mathbf{v}_1, \mathbf{v}_2, \ldots, \mathbf{v}_n\}\) is a basis for \(V\) then for a vector \(\mathbf{u} \in V\)

\[ \begin{align*} \mathbf{u} = u_1 \mathbf{v}_1 + u_2 \mathbf{v}_2 + \cdots + u_n \mathbf{v}_n, \end{align*} \]

and by the definition of a linear transformation

\[ \begin{align*} T(\mathbf{u}) = u_1 T(\mathbf{v}_1) + u_2 T(\mathbf{v}_2) + \cdots + u_n T(\mathbf{v}_n), \end{align*} \]

so \(T(\mathbf{u})\) depends on the vectors \(T(\mathbf{v}_1), T(\mathbf{v}_2), \ldots, T(\mathbf{v}_n)\). We can write this as the matrix equation

\[\begin{split} \begin{align*} T(\mathbf{u}) &= \begin{pmatrix} \uparrow & \uparrow & & \uparrow \\ T(\mathbf{v}_1) & T(\mathbf{v}_2) & \cdots & T(\mathbf{v}_n) \\ \downarrow & \downarrow & & \downarrow \end{pmatrix} \begin{pmatrix} u_1 \\ u_2 \\ \vdots \\ u_n \end{pmatrix} \\ &= A \mathbf{u}. \end{align*} \end{split}\]

In other words we can apply a linear transformation simply by multiplying \(\mathbf{u}\) by a matrix \(A\).

Definition 16 (Transformation matrix)

Let \(T : V \to W\) be a linear transformation and \(A\) be a matrix such that

\[\begin{split} \begin{align*} A = \begin{pmatrix} \uparrow & \uparrow & & \uparrow \\ T(\mathbf{v}_1) & T(\mathbf{v}_2) & \cdots & T(\mathbf{v}_n) \\ \downarrow & \downarrow & & \downarrow \end{pmatrix} \end{align*} \end{split}\]

then

\[ \begin{align*} T(\mathbf{u}) = A\mathbf{u}. \end{align*} \]

\(A\) is said to be the matrix representation of the linear transformation \(T\) (also known as the transformation matrix).

Example 19

A linear transformation \(T:\mathbb{R}^2 \to \mathbb{R}^2\) is defined by \(T: (x, y) \mapsto (3x + y, x + 2y)\). Calculate the transformation matrix and use it to calculate \(T(1, 1)\).

Solution

Since we are mapping from \(\mathbb{R}^2\) the transformation matrix is

\[ \begin{align*} A &= \begin{pmatrix} T(\mathbf{e}_1) & T(\mathbf{e}_2) \end{pmatrix} \end{align*} \]

Applying the transformation to the standard basis vectors

\[\begin{split} \begin{align*} T(\mathbf{e}_1) = T\begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} 3(1) + 0 \\ 1 + 2(0) \end{pmatrix} = \begin{pmatrix} 3 \\ 1 \end{pmatrix}, \\ T(\mathbf{e}_2) = T\begin{pmatrix} 0 \\ 1 \end{pmatrix} = \begin{pmatrix} 3(0) + 1 \\ 0 + 2(1) \end{pmatrix} = \begin{pmatrix} 1 \\ 2 \end{pmatrix}, \end{align*} \end{split}\]

so the transformation matrix is

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

Applying the transformation matrix to \((1, 1)\)

\[\begin{split} \begin{align*} T\begin{pmatrix} 1 \\ 1 \end{pmatrix} = A \cdot \begin{pmatrix} 1 \\ 1 \end{pmatrix} = \begin{pmatrix} 3 & 1 \\ 1 & 2 \end{pmatrix} \begin{pmatrix} 1 \\ 1 \end{pmatrix} = \begin{pmatrix} 4 \\ 3 \end{pmatrix}. \end{align*} \end{split}\]

The affects of the linear transformation from Example 19 is illustrated in Fig. 30. Note that the transformation \(T\) can be thought of as changing the basis of the vector space. The unit square with respect to the basis \(\{\mathbf{e}_1, \mathbf{e}_1\}\) has been transformed into a unit parallelogram with respect to the basis \(\{ T(\mathbf{e}_1), T(\mathbf{e}_2)\}\).

../_images/linear_transformation.svg

Fig. 30 The affect of applying a linear transformation \(T: (x,y) \mapsto (3x + y, x + 2y)\) to the vector \((1,1)\).#

Finding the transformation matrix from a set of images#

The calculation of the transformation matrix in Example 19 was straightforward as we knew what the transformation was. This will not always be a the case and we may know what the output (known as the image) of the transformation is but not the transformation itself. Consider a linear transformation \(T: \mathbb{R}^n \to \mathbb{R}^m\) applied to vectors \(\mathbf{u}_1, \mathbf{u}_2, \ldots, \mathbf{u}_n\). If \(A\) is the transformation matrix for \(T\) then

\[\begin{split} \begin{align*} A \begin{pmatrix} \uparrow & \uparrow & & \uparrow \\ \mathbf{u}_1 & \mathbf{u}_2 & \cdots & \mathbf{u}_n \\ \downarrow & \downarrow & & \downarrow \end{pmatrix} = \begin{pmatrix} \uparrow & \uparrow & & \uparrow \\ T(\mathbf{u}_1) & T(\mathbf{u}_2) & \cdots & T(\mathbf{u}_n) \\ \downarrow & \downarrow & & \downarrow \end{pmatrix} \end{align*} \end{split}\]

therefore

\[\begin{split} \begin{align*} A &= \begin{pmatrix} \uparrow & \uparrow & & \uparrow \\ T(\mathbf{u}_1) & T(\mathbf{u}_2) & \cdots & T(\mathbf{u}_n) \\ \downarrow & \downarrow & & \downarrow \end{pmatrix} \begin{pmatrix} \uparrow & \uparrow & & \uparrow \\ \mathbf{u}_1 & \mathbf{u}_2 & \cdots & \mathbf{u}_n \\ \downarrow & \downarrow & & \downarrow \end{pmatrix}^{-1} \end{align*} \end{split}\]

Theorem 6 (Determining the linear transformation given the inputs and image vectors)

Given a linear transformation \(T: \mathbb{R}^n \to \mathbb{R}^m\) applied to a set of \(n\) vectors \(\mathbf{u}_1, \mathbf{u}_2, \ldots, \mathbf{u}_n\) with known image vectors \(T(\mathbf{u}_1), T(\mathbf{u}_2), \ldots, T(\mathbf{u}_n)\) then the transformation matrix \(A\) for \(T\) is

(20)#\[A = (T(\mathbf{u}_1), T(\mathbf{u}_2), \ldots, T(\mathbf{u}_n)) \cdot (\mathbf{u}_1, \mathbf{u}_2, \ldots, \mathbf{u}_n)^{-1}.\]

Example 20

Determine the transformation matrix \(A\) for the linear transformation \(T:\mathbb{R}^2 \to \mathbb{R}^2\) such that

\[\begin{split} \begin{align*} T\begin{pmatrix} 1 \\ 1 \end{pmatrix} &= \begin{pmatrix} 4 \\ 3 \end{pmatrix}, & T\begin{pmatrix} 1 \\ 2 \end{pmatrix} &= \begin{pmatrix} 5 \\ 5 \end{pmatrix}. \end{align*} \end{split}\]
Solution

Using Gauss-Jordan elimination to determine the inverse of \((\mathbf{u}_1, \mathbf{u}_2)\)

\[\begin{split} \begin{align*} & \left( \begin{array}{rr|rr} 1 & 1 & 1 & 0 \\ 1 & 2 & 0 & 1 \end{array} \right) \begin{array}{l} \\ R_2 - R_1 \end{array} \\ \\ \longrightarrow \quad & \left( \begin{array}{rr|rr} 1 & 1 & 1 & 0 \\ 0 & 1 & -1 & 1 \end{array} \right) \begin{array}{l} R_1 - R_2 \\ \phantom{x} \end{array} \\ \\ \longrightarrow \quad & \left( \begin{array}{rr|rr} 1 & 0 & 2 & -1 \\ 0 & 1 & -1 & 1 \end{array} \right) \end{align*} \end{split}\]

so \((\mathbf{u}_1, \mathbf{u}_2)^{-1} = \begin{pmatrix} 2 & -1 \\ -1 & 1 \end{pmatrix}\). Right multiplying the image matrix

\[\begin{split} \begin{align*} A &= \begin{pmatrix} 4 & 5 \\ 3 & 5 \end{pmatrix} \begin{pmatrix} 2 & -1 \\ -1 & 1 \end{pmatrix} = \begin{pmatrix} 3 & 1 \\ 1 & 2 \end{pmatrix}. \end{align*} \end{split}\]

This is the transformation matrix from Example 19.

Inverse transformation#

An important property of linear transformations for computer graphics is that their affects can be reversed, i.e., if \(\mathbf{v} = T(\mathbf{u})\) then we can undo this to get \(\mathbf{u} = T^{-1}(\mathbf{v})\). The transformation \(T^{-1}\) is known as the inverse transformation.

Definition 17 (Inverse linear transformation)

Let \(T: V \to W\) be a linear transformation with the transformation matrix \(A\) then \(T\) has an inverse transformation denoted by \(T^{-1}: W \to V\) which reverses the affects of \(T\). If \(\mathbf{u} \in V\) and \(\mathbf{v} \in W\) then

\[\begin{split} \begin{align*} \mathbf{v} &= A \mathbf{u} \\ \therefore \mathbf{u} & = A^{-1}\mathbf{v}, \end{align*} \end{split}\]

where \(A^{-1}\) is the transformation matrix for \(T^{-1}\).

Example 21

Determine the inverse of the transformation \(T: \mathbb{R}^2 \to \mathbb{R}^2\) defined by \(T(x, y) \mapsto (3 x + y, x + 2 y)\) and calculate \(T^{-1}(4, 3)\).

Solution

We saw in Example 19 that the transformation matrix for \(T\) is

\[\begin{split} \begin{align*} A = \begin{pmatrix} 3 & 1 \\ 1 & 2 \end{pmatrix}, \end{align*} \end{split}\]

which has the inverse

\[\begin{split} \begin{align*} A^{-1} = \begin{pmatrix} \frac{2}{5} & -\frac{1}{5} \\ -\frac{1}{5} & \frac{3}{5} \end{pmatrix}. \end{align*} \end{split}\]

Determining the inverse transformation

\[\begin{split} \begin{align*} T^{-1}\begin{pmatrix} x \\ y \end{pmatrix} &= A^{-1} \cdot \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} \frac{2}{5} & -\frac{1}{5} \\ -\frac{1}{5} & \frac{3}{5} \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} \\ &= \begin{pmatrix} \frac{2}{5}x - \frac{1}{5}y \\ -\frac{1}{5}x + \frac{3}{5}y \end{pmatrix}. \end{align*} \end{split}\]

Calculating \(T^{-1}(4, 3)\)

\[\begin{split} \begin{align*} A^{-1} \begin{pmatrix} 4 \\ 3 \end{pmatrix} &= \begin{pmatrix} \frac{2}{5} & -\frac{1}{5} \\ -\frac{1}{5} & \frac{3}{5} \end{pmatrix} \begin{pmatrix} 4 \\ 3 \end{pmatrix} = \begin{pmatrix} 1 \\ 1 \end{pmatrix}. \end{align*} \end{split}\]

Composite linear transformations#

Definition 18 (Composite transformations)

Let \(T: V \to W\) and \(S : W \to X\) be two linear transformations over the vector spaces \(V, W\) and \(X\). The composition of \(S\) and \(T\) is the transformation \(S \circ T: V \to X\) defined by

\[ \begin{align*} (S \circ T)(\mathbf{u}) = S(T(\mathbf{u})), \end{align*} \]

for all vectors \(\mathbf{u} \in V\).

As before we want to be able to represent composite linear transformations as a matrix. If \(T\) and \(T\) are two linear transformations with transformation matrices \(A\) and \(B\) respectively, then the composite transformation \(S \circ T(\mathbf{u}\) is

\[ S \circ T(\mathbf{u}) = S(T(\mathbf{u})) = S(A\mathbf{u}) = B \cdot A \mathbf{u}.\]

If we let \(C = B \cdot A\) then

\[ S \circ T(\mathbf{u}) = C \mathbf{u}.\]

Theorem 7 (Composite transformation matrices)

Given two linear transformations \(T:V \to W\) and \(S:W \to X\) with transformation matrices \(A\) and \(B\) respectively then the composition \(S \circ T\) of the vector \(\mathbf{u} \in V\) is

(21)#\[S \circ T (\mathbf{u}) = C \mathbf{u}.\]

where \(C = B \cdot A\).

Example 22

Two linear transformations is defined as \(T:(x, y, z) \mapsto (2 x + 4 y, -x + 3 y, x + 2 y)\) and \(S:(x, y) \mapsto (2x + y - z, 3x + z, y - 2z)\).

(i) Determine the composite linear transformation \(S \circ T(\mathbf{u})\) for \(\mathbf{u} = (x, y, z)\).

Solution
\[\begin{split} \begin{align*} S \circ T\begin{pmatrix} x \\ y \\ z \end{pmatrix} &= S \left( T\begin{pmatrix} x \\ y \\ z \end{pmatrix} \right) = S \begin{pmatrix} 2 x + 4 \\ - x + 3y \\ x + 2 y \end{pmatrix} \\ &= \begin{pmatrix} 2(2 x + 4 y) + (-x + 3 y) - (x + 2 y) \\ 3(2 x + 4 y) + (x + 2 y) \\ (-x + 3 y) - 2(x + 2 y) \end{pmatrix} \\ &= \begin{pmatrix} 2 x + 9 y \\ 7 x + 14 y \\ -3 x - y \end{pmatrix}. \end{align*} \end{split}\]

(ii)   Determine the single transformation matrix \(C\) that represents \(S\circ T\).

Solution
\[\begin{split} \begin{align*} A &= \begin{pmatrix} 2 & 4 \\ -1 & 3 \\ 1 & 2 \end{pmatrix}, \\ B &= \begin{pmatrix} 2 & 1 & - 1 \\ 3 & 0 & 1 \\ 0 & 1 & -2 \end{pmatrix}, \\ \therefore C &= BA = \begin{pmatrix} 2 & 1 & - 1 \\ 3 & 0 & 1 \\ 0 & 1 & -2 \end{pmatrix} \begin{pmatrix} 2 & 4 \\ -1 & 3 \\ 1 & 2 \end{pmatrix} \\ &= \begin{pmatrix} 2 & 9 \\ 7 & 14 \\ -3 & -1 \end{pmatrix}. \end{align*} \end{split}\]

(iii)   Use your matrix \(C\) to determine \(S \circ T(\mathbf{u})\) for \(\mathbf{u} = (x, y)\).

Solution
\[\begin{split} \begin{align*} C \cdot \begin{pmatrix} x \\ y \\ z \end{pmatrix} = \begin{pmatrix} 2 & 9 \\ 7 & 14 \\ -3 & 1 \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} 2 x + 9 y \\ 7 x + 14 y \\ -3 x - y \end{pmatrix}. \end{align*} \end{split}\]