TExcelTAD
Home › Linear Algebra & Matrix Theory › Geometric Interpretation of Linear Transformations

Geometric Interpretation of Linear Transformations

A 2×2 matrix is easiest to understand by watching what it does to a shape: the unit square becomes a parallelogram spanned by the two columns, and every other figure is carried along. This lesson draws the basic transformations (rotation, scaling, reflection, shear, projection) in 2D and 3D, the same matrices that move every object in a game.

Watch the unit square

The unit square has corners 0\mathbf{0}, e1\mathbf{e}_1, e2\mathbf{e}_2 and e1+e2\mathbf{e}_1 + \mathbf{e}_2. A linear map with matrix A=[a1 a2]A = [\mathbf{a}_1\ \mathbf{a}_2] sends them to 0\mathbf{0}, a1\mathbf{a}_1, a2\mathbf{a}_2 and a1+a2\mathbf{a}_1 + \mathbf{a}_2: the square becomes the parallelogram spanned by the columns of AA. Straight lines stay straight, parallel lines stay parallel, the origin stays fixed, and equally spaced points stay equally spaced. Those four properties characterise linear maps geometrically.

The basic 2D transformations

Type Matrix What it does
Rotation by θ\theta [cos⁡θ−sin⁡θsin⁡θcos⁡θ]\begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} turns about 0\mathbf{0}, keeps lengths and angles
Uniform scale by ss [s00s]\begin{bmatrix} s & 0 \\ 0 & s \end{bmatrix} grows (s>1s > 1) or shrinks (0<s<10 < s < 1)
Non-uniform scale [a00b]\begin{bmatrix} a & 0 \\ 0 & b \end{bmatrix} stretches xx by aa and yy by bb
Reflection across a line through 0\mathbf{0} at angle φ\varphi [cos⁡2φsin⁡2φsin⁡2φ−cos⁡2φ]\begin{bmatrix} \cos 2\varphi & \sin 2\varphi \\ \sin 2\varphi & -\cos 2\varphi \end{bmatrix} mirror image
Horizontal shear [1k01]\begin{bmatrix} 1 & k \\ 0 & 1 \end{bmatrix} slides each point sideways by k⋅yk \cdot y
Projection onto the xx-axis [1000]\begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix} flattens to a line (not invertible)

Here they are applied to a small "house" shape:

python · try it yourself
import numpy as np
import matplotlib.pyplot as plt

house = np.array([[0, 0], [2, 0], [2, 1.5], [1, 2.5], [0, 1.5], [0, 0]]).T  # 2 x 6, columns = points
t = np.radians(40)
maps = {
    "rotate 40°":       np.array([[np.cos(t), -np.sin(t)], [np.sin(t), np.cos(t)]]),
    "scale (1.5, 0.5)": np.array([[1.5, 0], [0, 0.5]]),
    "reflect in y-axis": np.array([[-1, 0], [0, 1]]),
    "shear k = 0.8":    np.array([[1, 0.8], [0, 1]]),
}
fig, axes = plt.subplots(1, 4, figsize=(12, 3.2))
for ax, (name, A) in zip(axes, maps.items()):
    img = A @ house                                  # transform all points at once
    ax.plot(*house, color="lightgray", lw=2)
    ax.plot(*img, color="tab:blue", lw=2)
    ax.set_title(name); ax.set_aspect("equal"); ax.set_xlim(-3, 4); ax.set_ylim(-1, 4)
    ax.axhline(0, lw=0.5, color="k"); ax.axvline(0, lw=0.5, color="k")
for name, A in maps.items():
    print(f"{name:18s} columns: {np.round(A[:, 0], 3).tolist()} {np.round(A[:, 1], 3).tolist()}")
rotate 40°         columns: [0.766, 0.643] [-0.643, 0.766]
scale (1.5, 0.5)   columns: [1.5, 0.0] [0.0, 0.5]
reflect in y-axis  columns: [-1, 0] [0, 1]
shear k = 0.8      columns: [1.0, 0.0] [0.8, 1.0]

The grey outline is the original, blue the image. Note that the whole shape is transformed with one matrix product, A @ house, applied to all points stored as columns.

Rotations in 3D

In R3\mathbb{R}^3 a rotation turns about an axis through 0\mathbf{0}. The rotations about the coordinate axes keep one coordinate fixed and act as a 2D rotation on the other two:

Rx(θ)=[1000cos⁡θ−sin⁡θ0sin⁡θcos⁡θ]Ry(θ)=[cos⁡θ0sin⁡θ010−sin⁡θ0cos⁡θ]Rz(θ)=[cos⁡θ−sin⁡θ0sin⁡θcos⁡θ0001]R_x(\theta) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos\theta & -\sin\theta \\ 0 & \sin\theta & \cos\theta \end{bmatrix} \qquad R_y(\theta) = \begin{bmatrix} \cos\theta & 0 & \sin\theta \\ 0 & 1 & 0 \\ -\sin\theta & 0 & \cos\theta \end{bmatrix} \qquad R_z(\theta) = \begin{bmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix}

(RyR_y has its signs "swapped" so that every rotation is counter-clockwise when you look down its axis towards the origin in a right-handed system.) Any 3D rotation is a product of these, but the order matters: rotations about different axes do not commute.

python · try it yourself
import numpy as np

def Rx(deg):
    t = np.radians(deg); c, s = np.cos(t), np.sin(t)
    return np.array([[1, 0, 0], [0, c, -s], [0, s, c]])

def Rz(deg):
    t = np.radians(deg); c, s = np.cos(t), np.sin(t)
    return np.array([[c, -s, 0], [s, c, 0], [0, 0, 1]])

v = np.array([1.0, 0.0, 0.0])
print("Rx(90) Rz(90) v:", np.round(Rx(90) @ Rz(90) @ v, 6).tolist())
print("Rz(90) Rx(90) v:", np.round(Rz(90) @ Rx(90) @ v, 6).tolist())
R = Rx(30) @ Rz(70)
print("R^T R == I:", np.allclose(R.T @ R, np.eye(3)), " det R:", round(float(np.linalg.det(R)), 6))
Rx(90) Rz(90) v: [0.0, 0.0, 1.0]
Rz(90) Rx(90) v: [0.0, 1.0, 0.0]
R^T R == I: True  det R: 1.0

Rotation matrices are orthogonal (RTR=IR^TR = I, so R−1=RTR^{-1} = R^T, which is cheap) and have determinant +1+1. Reflections are orthogonal with determinant −1-1 (Orthogonal Functions and Orthogonal Matrices).

Reading a matrix geometrically

Clue Meaning
columns orthonormal, det⁡=1\det = 1 rotation
columns orthonormal, det⁡=−1\det = -1 reflection (possibly combined with a rotation)
diagonal scaling along the axes
det⁡=0\det = 0 squashes the plane onto a line or point (projection-like)
∣det⁡∣\lvert \det \rvert area scale factor (determinants)
A2=AA^2 = A projection

In software: rotate, scale and shear in games

  • 2D games rotate sprites and velocity vectors with the 2×2 rotation matrix (Rotation in 2D); a non-uniform scale squashes a character when it lands; a shear gives italic text or a cheap "wind" sway on grass.
  • 3D engines build each object's transform from scale, rotation and translation, in that order (T⋅R⋅ST \cdot R \cdot S applied to column vectors), with translation added through homogeneous coordinates (Translate, Rotate, Scale).
  • Euler angles describe a rotation as three axis rotations; because the order matters and two axes can line up, they suffer from gimbal lock (Euler Angles and Gimbal Lock). Engines therefore store rotations as quaternions or axis-angle and convert to a matrix only for rendering (Rotations: Matrices vs Quaternions).
  • Drift: multiplying many rotation matrices in floating point slowly breaks orthogonality (the object starts to skew); engines re-orthonormalise periodically.

Exercises

Exercise 1: Identify the transformation

Describe geometrically the maps with matrices (a) [0−110]\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}, (b) [−100−1]\begin{bmatrix} -1 & 0 \\ 0 & -1 \end{bmatrix}, (c) [2002]\begin{bmatrix} 2 & 0 \\ 0 & 2 \end{bmatrix}, (d) [100.51]\begin{bmatrix} 1 & 0 \\ 0.5 & 1 \end{bmatrix}.

Answer

(a) rotation by 90°, (b) rotation by 180° (point reflection through 0\mathbf{0}), (c) uniform scaling by 2, (d) vertical shear by 0.5.

Solution

(a) e1→e2\mathbf{e}_1 \to \mathbf{e}_2, e2→−e1\mathbf{e}_2 \to -\mathbf{e}_1: the rotation matrix with θ=90∘\theta = 90^\circ. (b) Every vector is negated: θ=180∘\theta = 180^\circ. (c) Both columns are doubled. (d) e1→[1,0.5]\mathbf{e}_1 \to [1, 0.5], e2\mathbf{e}_2 fixed: each point moves up by 0.5⋅x0.5 \cdot x.

Exercise 2: Where does the square go?

Under A=[2113]A = \begin{bmatrix} 2 & 1 \\ 1 & 3 \end{bmatrix}, find the images of the corners of the unit square. What is the area of the resulting parallelogram?

Answer

Corners 0\mathbf{0}, [2,1][2, 1], [1,3][1, 3], [3,4][3, 4]; area 5.

Solution

The corners go to 0\mathbf{0}, column 1 =[2,1]= [2, 1], column 2 =[1,3]= [1, 3], and their sum [3,4][3, 4]. The area of the parallelogram spanned by [2,1][2, 1] and [1,3][1, 3] is ∣2⋅3−1⋅1∣=5\lvert 2 \cdot 3 - 1 \cdot 1 \rvert = 5, the absolute value of det⁡A\det A.

Exercise 3: Reflection across y=xy = x via the formula

Use the reflection formula with φ=45∘\varphi = 45^\circ and confirm you get [0110]\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}.

Answer

cos⁡90∘=0\cos 90^\circ = 0, sin⁡90∘=1\sin 90^\circ = 1, giving [0110]\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}.

Solution
2φ=90∘:[cos⁡90∘sin⁡90∘sin⁡90∘−cos⁡90∘]=[0110]2\varphi = 90^\circ: \quad \begin{bmatrix} \cos 90^\circ & \sin 90^\circ \\ \sin 90^\circ & -\cos 90^\circ \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}

This swaps xx and yy, the mirror in the line y=xy = x.

Exercise 4: Rotate about a vertical axis

In a yy-up game world, a turret at the origin points along +z=[0,0,1]+z = [0, 0, 1]. Using Ry(θ)R_y(\theta), where does it point after turning by θ=90∘\theta = 90^\circ? Write RyR_y in NumPy and check.

Answer

It points along +x+x: [1,0,0][1, 0, 0].

Solution

Ry(90∘)R_y(90^\circ) has cos⁡=0\cos = 0, sin⁡=1\sin = 1, so it maps [0,0,1][0, 0, 1] to [sin⁡θ,0,cos⁡θ]=[1,0,0][\sin\theta, 0, \cos\theta] = [1, 0, 0].

python · try it yourself
import numpy as np
def Ry(deg):
    t = np.radians(deg); c, s = np.cos(t), np.sin(t)
    return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]])
print(np.round(Ry(90) @ [0, 0, 1], 6).tolist())
[1.0, 0.0, 0.0]

Test yourself

What does the matrix [1301]\begin{bmatrix} 1 & 3 \\ 0 & 1 \end{bmatrix} do to the plane?

  1. Rotates it
  2. A horizontal shear: each point moves sideways by 3⋅y3 \cdot y
  3. Scales xx by 3
  4. Reflects it

For a 3D rotation matrix RR, what is R−1R^{-1}?

  1. RTR^T
  2. −R-R
  3. RR itself
  4. It has no inverse

Do rotations about the xx-axis and the zz-axis commute?

  1. Yes, always
  2. Only in left-handed systems
  3. Only for angles under 90°
  4. No, the order changes the result