Translation and Rotation Matrices

Introduction

Welcome to 3D Worlds and Matrix Transformations! We're embarking on an exciting journey into the mathematical foundations that power modern 3D graphics. In this first lesson, we'll explore one of the most fundamental concepts in computer graphics: how we use matrices to move and rotate objects in 3D space.

Today, we'll focus on understanding translation and rotation matrices. By the end of this lesson, we'll have built a solid theoretical foundation that will prepare us for the hands-on work ahead. Think of this as laying the groundwork for everything we'll create together in this course.

Understanding 3D Space and Vectors

Before we dive into matrices, let's establish our foundation in 3D space. In computer graphics, we work with two essential mathematical objects: positions and vectors.

A position represents a specific point in 3D space using three coordinates (x,y,z)(x, y, z). For example, the point (3,5,2)(3, 5, 2) tells us exactly where something is located. A vector, on the other hand, represents a direction and magnitude. Think of it as an arrow pointing from one place to another, like moving 2 units right, 3 units up, and 1 unit forward, which we'd write as the vector (2,3,1)(2, 3, 1).

The beauty of vectors lies in their versatility: they can represent movement, orientation, velocity, or any directional quantity in our 3D world. When we want to move an object from one position to another, we're essentially adding a vector to a position.

For visual clarity in our diagrams and examples, we'll often illustrate concepts using 2D coordinate space with just (x,y)(x, y) coordinates. However, it's important to understand that every principle we discuss applies directly to 3D space with (x,y,z)(x, y, z) coordinates, and even extends to higher-dimensional spaces. The mathematical concepts remain identical—we simply add more coordinate components as needed.

Introducing Bases

To truly understand how matrices transform 3D space, we need to grasp the concept of a basis. A basis is a set of vectors that defines our coordinate system—think of it as the fundamental "rulers" we use to measure and describe positions in 3D space.

The standard basis in 3D consists of three unit vectors:

  • i = [100]\begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix} (points along the x-axis)
  • j = [010]\begin{bmatrix} 0 \\ 1 \\ 0 \end{bmatrix} (points along the y-axis)
  • k = [001]\begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix} (points along the z-axis)

Here's the key insight: when we write a position like (1,5,3)(1, 5, 3), we're actually expressing it as a linear combination of these basis vectors:

(1,5,3)=1i+5j+3k(1, 5, 3) = 1 \cdot \mathbf{i} + 5 \cdot \mathbf{j} + 3 \cdot \mathbf{k}

This means: "Start at the origin, move 1 unit in the i direction, then 5 units in the j direction, then 3 units in the k direction." The coordinates (1, 5, 3) are simply the coefficients that tell us how much of each basis vector to use.

This perspective is crucial because it reveals that every vector is really a recipe for combining basis vectors. When we transform space with matrices, we're changing what those basis vectors i, j, and k point toward, which automatically changes how every position and vector in our scene is interpreted.

Sign up

Join the 1M+ learners on CodeSignal

Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal