Page 21: Rotations in 3D

Spring 2026 Sample Solution

Rotations turn out to be much more complicated in 3D than in 2D.

In 2D, rotations were simple enough that we didn’t talk about them much. They had this matrix with sines and cosines. They spun things around. They had a center (at the origin), that we could shift around by composing with translations. We could measure rotations easily with an angle (in either degrees or radians).

In 3D, rotations are more complicated. Specifying them requires providing enough information, which means we need to understand rotations so that we can use them effectively.

The lecture videos explain rotations well. I think this is a topic where waving my hands actually works. There are lots of physical props (especially at the beginning). The lectures mix the three specific concepts in with the general math.

Rotation Facts

Rotations are a type of rigid transformation. Rigid transformations preserve the distance and handedness between points. The distance between two points is not changed when they are transformed. The object will not be mirrored by a rigid transformation.

Defining handedness

I found it challenging to define handedness precisely. So I asked Gemini, and it provided a few definitions:

Here are a few different ways to complete that sentence, depending on how technical you want to be:

The Analogy Approach (Most Intuitive):

“Rigid transformations preserve handedness. This means no combination of moving or rotating will ever mirror an object, just as you can never rotate a right shoe to make it perfectly fit on a left foot.”

The Geometry Approach (More Technical):

“Rigid transformations preserve handedness. This means the relative order of an object’s local X, Y, and Z axes is permanently locked, ensuring the object can never be reflected or turned inside out.”

The Short & Punchy Approach:

“Rigid transformations preserve handedness. This means an object can be translated or rotated anywhere in space, but it can never be mirrored into its opposite reflection.”

Translations are also a rigid transformation. Rotations are rigid transformations where one point does not move (in a translation, all points move by the same amount).

In 2D, only one point didn’t move in a rotation (the center). The center of rotation was a point. In 3D, an entire line doesn’t move in a rotation. A way to think about this: if the 2D planes were stacked in 3D, each plane would have its center, and those center points would be on a line. We call this line of points that do not change the axis of rotation.

The standard 2D rotation is a rotation around the Z axis.

Of course, we could rotate around any of the three coordinate axes.

Here, we are drawing the coordinate axes and you can see the cubes rotating around each. The bottom row is an orthographic view. Notice that the Z rotation is the standard 2D rotation.

Every rotation has an axis. And the axis can be any line. In order to specify a rotation, we need to specify both the amount of rotation and the axis of rotation.

Composition of Rotations

The composition of any sequence of rotations is a rotation. Put simply, if you rotate an object, rotate it again, then rotate it a third time, there will always be one rotation that gets you from the initial state to the final state. No matter how many rotations you put together.

In a single axis (like in 2D): . That is, the composition of rotations is the same as adding the angles. We can simply measure the amount of rotation about that axis. This works no matter what the axis is - providing that both rotations have the same axis.

If the axes are different, the composition of the rotations is still a rotation, except that it is (generally) not a rotation about either of the axes! It is a rotation by some amount, around some other axis: . We would need to figure out both what the new axis is, and the amount. This turns out to be tricky.

And to make things even trickier, transformations do not commute. If we have two rotations, . Here is an example (the demo was created by Codex 5.3 in Co-Pilot). The example is a 90 degree rotation about X and a 90 degree rotation around Z - in different orders.

This means that even if we have the same axes, we can not combine the rotations if there is another rotation in between. So, for example, if we have , the combination of the first x and y is an axis that is not x, so it cannot be combined easily with the second x.

One Solution

While rotations are transformations of some amount around some axis, that isn’t necessarily an easy way to compute with them.

Another fact about rotations is that they are linear transformations. A rotation in 3D can be represented as a 3x3 matrix. Rotation matrices (the subset of all matrices that are rotations) have some special properties:

  1. Their rows are mutually orthogonal. Their columns are mutually orthogonal.
  2. Each row has magnitude one (it has vector length 1). Each column also has that same property.
  3. The matrix has determinant 1.

The linear algebra term for properties 1 and 2 is “ortho-normal”. The fact that the determinant is positive means we call the matrix positive.

If we can figure out the matrix for our rotations, we can work with them easily. Matrices (and the transformations they encode) compose by multiplication so that we can combine transformations as we need.

However, there are some problems with using matrices to represent rotations. Some of the big ones:

  1. They have no intuitive meaning. It is difficult to interpret (or specify) the 9 numbers of a rotation matrix to mean some specific goal.
  2. It is 9 numbers, which is a lot. Especially when we need to do computations. Every composition involves multiplying two of these matrices together.
  3. The 9 numbers must have the exact mathematical properties (rows/columns having unit magnitude, rows/columns being orthogonal). If we have small computation errors, the matrix will stop being a rotation matrix. These errors tend to build up over time.
  4. There is no easy way to interpolate between transformations. For example, there is no easy “half way”. Computing a transformation that does “half” requires taking the square root of the matrix (since the operation composed with itself will be the transformation). Matrix square roots are hard.

That said, matrices are a common choice for representing the transformations in 3D graphics systems. They are more general - as they can represent any affine transformation (not just rotations). But, in order to handle rotations well, we need a better choice.

The choice made by most graphics systems (including three) is to specify and store rotations using some other mechanism, and then to convert these to matrices for the final combinations.

If you remember, internally, three keeps translation, rotation, and scale separate. That allows us to compute with rotations using something other than matrices. Internally, three uses unit quaternions to represent rotations. But before we can explain them, we need to understand more about rotations.

Other representations of rotations

Rotation matrices are not “user friendly” - the 9 numbers are hard to interpret, and have complex relationships that must be maintained.

The other main representations of rotations are based on the work of mathematician Leonhard Euler. Euler is pronounced “oy-ler” (rhymes with boiler). Do not say “you-ler”. Even though he lived in the 1700s, he was responsible for many of the important foundations of computer graphics. He has many different mathematical techniques named after him.

Euler was a very important mathematician who invented many things. Confusingly, he invented both of the main ways we work with rotations. So, they could both be called “Euler Angles”. In fact the term “Euler Angles” is ambiguous. It’s an important enough term that I will tell you the common usage in graphics, but be aware: it can mean different things.

There are two key theorems that Euler showed. Each leads to a practical way to specify angles that we use in computer graphics:

  1. Any rotation can be expressed as a single rotation around an arbitrary axis. This means that if you compose a bunch of rotations, the result is a rotation around some axis. It might be a different axis than the rotations you composed, but there will be some axis and some amount of rotation around that axis.
  2. Any rotation can be expressed as 3 rotations around fixed axes. That means I can pick 3 axes, for example X, Y and Z. Any rotation (the composition of an arbitrary sequence of rotations) can be turned into a sequence of three rotations around those axes in that order.

Each one of these theorems leads to a way to represent and specify rotations.

With the first theorem, it suggests we can specify a rotation by giving the axis (a line or vector) and a single angle (the amount to rotate around that line).

With the second theorem we can choose convention (a list of axes), and then give the amount to rotate around each (3 numbers). An interesting thing about this: it is very general. As long as the consecutive axes are not parallel, any choice of axes can work. In computer graphics, we tend to prefer to pick the global coordinate axes (x,y,z). But in other situations, they use different axes.

This second method of specifying rotations, as the amount of rotation around three pre-determined axes, is commonly known in graphics as Euler Angles. We will explore them on the next page.

Next: Page  22 - Euler Angles Toys