Chapter 12
Change of Basis
The same vector looks different depending on whose coordinate system you're using. How do you translate between viewpoints?
When you write a vector as , you're saying "3 units along the x-axis, 1 unit along the y-axis." But that's a choice. Someone else might use a different pair of reference directions -- rotated, scaled, skewed -- and they'd describe the exact same arrow in space with completely different numbers. Neither description is wrong. They're just using different coordinates.
This chapter is about the translation layer between those descriptions. The matrix that converts coordinates from one basis to another is called the change of basis matrix, and the formula lets you express the same transformation from a different point of view. If you've ever converted between world space and camera space in a graphics engine, you've already done this.
Two coordinate systems
Let's set up two different ways to describe points in the plane. The standard basis uses the usual horizontal and vertical axes: and . That's the gray grid below.
Now consider an alternative basis with vectors and . These are rotated 45 degrees from the standard axes. The green grid below shows the coordinate lines of this alternative system.
Take the vector that we call in the standard basis. In the alternative basis, that same arrow is described as -- meaning 2 units along and unit along . Different numbers, same arrow.
The gray grid is the standard coordinate system. The green grid is the alternative basis -- rotated 45 degrees. The same vector is in standard coordinates or in the alternative basis. The dashed lines show the decomposition: 2 units of plus units of .
Verify by hand: . Same arrow, different description.
The change of basis matrix P
The matrix that translates between these two descriptions is built from the alternative basis vectors. Pack and as the columns of a matrix :
This matrix converts coordinates from the alternative basis to the standard basis. If a vector has coordinates in the alternative system, then:
That's just the definition of what "coordinates in a basis" means -- a linear combination of the basis vectors. The matrix packages that linear combination into a single multiplication.
To go the other direction -- standard to alternative -- you use the inverse:
Standard coordinates go in, alternative coordinates come out.
The columns of are the alternative basis vectors expressed in the standard basis. Multiplying by a vector in alternative coordinates gives you that same vector in standard coordinates. The inverse goes the other way.
Think of as a translator. It doesn't change the vector -- it changes the language used to describe it. The arrow in space stays put. Only the numbers change.
A transformation in another basis
Now here's where change of basis gets genuinely powerful. Suppose you have a transformation described by a matrix in the standard basis. What does that same transformation look like to someone using the alternative basis?
Let's use a horizontal stretch by a factor of 2:
In the standard basis, this is simple: double the -coordinate, leave the -coordinate alone. But in the alternative basis -- the one rotated 45 degrees -- this transformation looks different. It's no longer a simple axis-aligned stretch because the alternative axes don't line up with the stretch direction.
To find the matrix that describes the same transformation in the alternative basis, you use the similarity formula:
Here's what each step does to a vector in alternative coordinates:
- : Translate to standard coordinates (the only language speaks)
- : Apply the transformation (in standard coordinates)
- : Translate the result back to alternative coordinates
The pipeline: start with alternative coordinates , convert to standard with , apply the transformation , convert back with . Below, the actual geometric effect: the vector gets stretched horizontally to . The geometry is the same no matter which coordinate system describes it.
Let's compute explicitly:
First, :
Then, :
In the standard basis, the transformation is the clean -- a simple horizontal stretch. In the rotated basis, the same transformation becomes -- no longer diagonal, because the alternative axes aren't aligned with the stretch direction. The geometry hasn't changed. The description has.
Same transformation, different descriptions
This is the key point: and describe the same geometric transformation. They're the same function written in different coordinate languages. Let's see this directly.
Apply to the vector in standard coordinates:
Apply to the same vector written as in alternative coordinates:
Now convert that result back to standard coordinates: .
Same answer. Both paths land at the same geometric point.
Left: the transformation A stretches horizontally, taking to . Right: the same arrow, described in the alternative basis, goes from to under . Both paths arrive at the same point in space. The matrices are different because the coordinate systems are different.
Two matrices related by are called similar matrices. They're not the same matrix, but they represent the same underlying transformation. Think of it like the number "five" written as 5, V, 101 in binary, or cinco -- different representations of the same thing.
The formal bit
Here are the key formulas, stated precisely.
Change of basis matrix: If is an alternative basis, the change of basis matrix is:
Its columns are the alternative basis vectors expressed in the standard basis.
Converting coordinates:
goes from alternative to standard. goes from standard to alternative.
Similarity transform -- expressing a transformation in a different basis:
is the matrix of the transformation in the standard basis. is the matrix of the same transformation in the alternative basis. They describe the same geometric operation.
Why it works: For any vector in alternative coordinates:
Reading right to left: translates to standard coordinates, applies the transformation, translates the result back to alternative coordinates. The sandwich structure ensures the transformation is done in the language understands (standard coordinates), with automatic translation on both ends.
Worked example: world space to camera space
Here's where this becomes immediately useful. In 3D graphics, every object lives in world space -- a single global coordinate system. But the screen shows what the camera sees, and the camera has its own coordinate system defined by three vectors:
- look (or forward): the direction the camera is pointing
- right: the direction to the camera's right
- up: the direction above the camera
These three vectors form a basis -- the camera's basis. The change of basis matrix has these vectors as its columns:
To convert a point from world coordinates to camera coordinates, you multiply by :
Here's what this looks like in code:
import numpy as np
# Camera is at the origin, looking along (0.707, 0, 0.707)
# tilted 45 degrees from the z-axis
look = np.array([0.707, 0, 0.707])
right = np.array([0.707, 0, -0.707])
up = np.array([0, 1, 0])
# Build the change of basis matrix
P = np.column_stack([right, up, look])
# A point in world space
point_world = np.array([10, 5, 10])
# Convert to camera space
P_inv = np.linalg.inv(P)
point_camera = P_inv @ point_world
print(point_camera) # [14.14, 5.0, 0.0]
The world point is at in camera coordinates. The camera is looking right at it (the look component is 0), and it's 14.14 units to the right and 5 units up from the camera's viewpoint.
This is exactly the pattern: converts from one coordinate system to another. In game engines, this matrix is computed every frame as the camera moves. Every vertex in the scene gets multiplied by it. The geometry of the world doesn't change -- only the description, as seen from the camera's perspective.
If you want to apply a transformation (like lighting or physics) that's naturally described in camera space, you'd use the full pattern: convert to camera space, apply the transformation, convert back to world space.
Key Takeaway: Change of basis is . It expresses the same transformation from a different point of view. The geometry doesn't change -- only the description. The matrix (whose columns are the new basis vectors) translates between coordinate systems, and the similarity transform rewrites a transformation in the new language.
What's next
Some transformations become beautifully simple in the right basis. A messy matrix full of off-diagonal entries might secretly be just a scaling operation -- if you look at it from the right coordinate system. The vectors that define that perfect basis, the one where the transformation becomes pure scaling along each axis, are called eigenvectors. Finding them is one of the most important ideas in all of linear algebra. That's Chapter 13: Eigenvectors & Eigenvalues.