</>
Vizly

Three-Dimensional Linear Transformations

June 12, 20265 min
MathLinear Algebra3DTransformations

Chapter 5. Good news: nothing new to learn here. Everything from flat 2D carries over to 3D. You just add a third basis vector and a third number. Same rules, one more direction.

Start here

This is a short, friendly chapter. If Chapter 3 made sense, this one is almost free. We are just taking the same ideas and adding one more dimension. The reason it gets its own chapter is that 3D is where determinants (Chapter 6) and cross products (Chapter 10) live, so it helps to get comfortable here first.

Watch the original

Follow along with 3Blue1Brown: Three-dimensional linear transformations


Three basis vectors now

In 2D we had two basis vectors, î (right) and ĵ (up). In 3D we add a third, (written k-hat), pointing out toward you along the z-axis.

î = [1, 0, 0]    points right
ĵ = [0, 1, 0]    points up
k̂ = [0, 0, 1]    points out of the page

A 3D vector like [2, 1, 3] means: 2 steps right, 1 step up, 3 steps out. Same idea as before, just one more number.


A 3D transformation is still "where do the basis vectors land"

Same rule as Chapter 3. To describe a transformation of 3D space, you only need to know where the three basis vectors go. Write each landing spot as a column, and you get a 3 by 3 matrix.

| 2  0  1 |     column 1 = where î lands
| 0  3  0 |     column 2 = where ĵ lands
| 1  0  4 |     column 3 = where k̂ lands

Three columns, three landing vectors. Nothing changed except the count.


Matrix times vector: same recipe

To apply a 3D matrix to a vector, scale each column by the matching coordinate and add them up. Exactly like 2D, just three terms instead of two.

| a b c |   | x |       | a |       | b |       | c |
| d e f | * | y | = x * | d | + y * | e | + z * | f |
| g h i |   | z |       | g |       | h |       | i |

A quick number example:

| 2 0 1 |   | 1 |       | 2 |       | 0 |       | 1 |     | 2+0+0 |   | 2 |
| 0 3 0 | * | 0 | = 1 * | 0 | + 0 * | 3 | + 0 * | 0 |  = | 0+0+0 | = | 0 |
| 1 0 4 |   | 0 |       | 1 |       | 0 |       | 4 |     | 1+0+0 |   | 1 |

We fed in î and got back the first column, just as promised.


Multiplying 3D matrices

Composition works the same too. Multiplying two 3 by 3 matrices means doing one 3D transformation, then another. You compute it by sending each column of the first matrix through the second. The only difference from Chapter 4 is that there are three columns to push through instead of two.


A useful picture: 3D rotations

Rotating 3D space is something you do constantly without thinking, every time you turn an object in a video game or rotate a 3D model. Each rotation is a 3 by 3 matrix. Spinning around the z-axis, for example, leaves alone and rotates î and ĵ in the flat xy-plane:

| cos t   -sin t   0 |
| sin t    cos t   0 |
|   0        0     1 |

Notice the bottom-right 1 and the zeros around it: that is the matrix saying "leave the z direction untouched, just rotate the other two".


Why this matters later

  • Graphics and games are all 3D linear transformations: rotate, scale, then project to a 2D screen. Each is a matrix, multiplied together.
  • Robotics uses 3D rotation matrices to track where an arm or joint is pointing.
  • Determinants (next chapter) measure how much volume a 3D transformation scales, which only makes sense once you can picture 3D grids stretching.
The mental model to keep

3D is 2D plus one more basis vector. Columns are still landing spots. Matrix times vector is still scale the columns and add. You already knew all of this.


Quick gotchas

Column order is î, ĵ, k̂. First column is where î goes, and so on. Same as 2D.

A 3 by 3 matrix has 9 numbers but only 3 ideas. It is three landing vectors. Do not let the bigger grid scare you.

You cannot easily picture past 3D, and that is fine. The algebra keeps working in 4D, 100D, any D. The pictures stop, the rules do not.


What you walked away with

  • 3D adds a third basis vector and a third coordinate.
  • A 3D transformation is a 3 by 3 matrix whose columns are the landing spots of î, ĵ, .
  • Matrix times vector and matrix times matrix work exactly as in 2D, with one extra term.

Next up, Chapter 6: the determinant. We will measure exactly how much a transformation stretches or squishes area and volume, and find out what it means when that number hits zero.

Edit this page on GitHub