I originally created this page partly to gain experience embedding LaTeX in WordPress posts and pages, partly to gain experience using LaTeX to render math equations, and partly to document my exploration of rotation matrices. [See my *Matrix Rotation* and *Matrix Magic* posts for an overview.]

To my surprise, this turned into one of my most viewed pages. Apparently, lots of other people find the topic as fascinating as I do.

[2023/17/01] So, especially given that people have noticed this page and have been meaning to update it anyway, I finally got myself a Round Tuit. Added some stuff and moved the quantum gate stuff to the Quantum Qubit Math page.

Note: The following assumes the reader understands the basic idea that matrices transform a vector into a new vector. Therefore, they transform all the points of a vector space. This page only addresses matrices that rotate the space.

### 2D

As possibly the simplest example of a transformation matrix, let’s start with a 2D identity matrix:

We call it **I²** because it’s the identity matrix for two dimensional transformations. Specifically, it’s the *no-change* transformation in two dimensions. It changes all vectors into themselves.

The trick is to view a transformation matrix as consisting of vertical column vectors, one for each basic axis.

In the two-dimensional case there are two vertical column vectors, usually called *i-hat* and *j-hat*. These start off as unit vectors along the X-axis and Y-axis. They are initially identical to *x-hat* (1,0) and *y-hat* (0,1), the unit vectors that define the axes. (The “hat” symbol denotes a unit vector.)

The four matrix values, seen as two column vectors, specify where *i-hat* and *j-hat* end up. That’s the key. The matrix values determine how those two vectors get transformed. The matrix values *are* the new values for those vectors. (That’s why we don’t use *x-hat* and *y-hat*, which might have seemed like obvious choices. Those vectors define the axes and can’t change.)

So, a matrix describes a transformation of a space, in this case the 2D plane. Such a transformation might be a scaling, a rotation, a shear, or some combination. Notably, in all cases, the origin stays the same.

In the case of the identity matrix, *i-hat* is (1,0) and *j-hat* is (0,1), which is exactly where they started. That’s what makes the identity matrix the identity matrix. Nothing changes.

A 2D rotation matrix looks like this:

The name, identifies it as a **R**otation matrix. The superscript indicate that it’s a rotation in two dimensions, and the subscript that the rotation involves the **X** and **Y** coordinates (exactly as we’d expect in two dimensions). Also, note that **R** is a *function* that requires an input, the angle *theta* (*θ*).

The result is a matrix with four values based on the sine and cosine of *θ*. Given the following table, it’s easy to plug in values for four well-known cases of angle *θ*:

0° | 90° | 180° | 270° | |

sin θ | 0 | +1 | 0 | -1 |

cos θ | +1 | 0 | -1 | 0 |

So, plugging in the values from the first colum, the first rotation matrix, a rotation of zero degrees, looks like this:

Which is the identity matrix. A rotation of zero degrees does nothing.

The other three matrices for the table values look like this:

Of course, other angles result in different (non-integer) values.

For instance, a 10-degree rotation matrix looks like this:

The values are just *cos*(10°) and *sin*(10°) plugged into their appropriate spots.

### 3D

Here’s the 3D identity matrix:

As with the **I²** matrix, we call this **I³** because it’s the identity matrix for three dimensions. Also as in 2D, the identity matrix is the null (or zero-degree) transformation for 3D rotation. Applying it to a vector transforms the vector into itself.

In 3D we add a third transformation vector, *k-hat*, which conceptually starts off as identical to *z-hat*, the unit vector defining the Z-axis. We also need a third component for all three vectors:

As before, the trick is that the imagined transformation vectors (in this case *i-hat*, *j-hat*, and *k-hat*) start identical to the basis unit vectors and are transformed to the values given by the matrix.

Here’s the matrix for 3D rotation involving the **X** and **Y** coordinates:

It’s obviously similar to the matrix — we’ve just added the Z-axis. In fact, although the **X** and **Y** coordinates are the ones that change, the rotation is actually around the Z-axis. This is also true in the 2D case above, but in two dimensions the Z-axis vanishes into the origin, so rotation in 2D is around the origin (one can imagine a Z-axis sticking out of the 2D plane).

The three matrices for **XY** rotations of 90°, 180°, and 270° look very much like the three 2D ones above:

The difference being the identity value in the lower-right corner. This represents that the coordinates on the Z-axis do not change.

Here’s the matrix for 3D rotation involving the **X** and **Z** coordinates (in other words, around the Y-axis):

And here are the three matrices for **XZ** rotations of 90°, 180°, and 270°:

Similar to the XY rotation matrices above, but with the four “rotator” values distributed to different cells. The *x-hat* values are the same, but the *z-hat* values now rotate and *y-hat* keeps the Y-axis coordinate values fixed.

Finally, here’s the matrix for 3D rotation involving the **Y** and **Z** coordinates (rotating around the X-axis):

The three matrices for X-axis rotations of 90°, 180°, and 270° are:

The instances for specific rotations look much like the ones shown above.

### 4D

Here’s the 4D identity matrix:

The naming pattern should be familiar by now.

Here’s the matrix for 4D rotation around the Y *and* Z axes:

This is the tesseract rotation that seems to move the cubes along the X-axis (the first mode of rotation seen in the video).

The dual-axis rotation allows rotation of all orientations of cubes in 4D space.

In a tesseract, the four cubes with extent in X *or* W shift between extending in those axes, while the other four cubes (who have both X *and* W extent), rotate around either their Y or Z axis (depending on which they have).

In a (3D) cube, 4D rotation rotates the X extent into the W dimension and back (reversed), which allows “flipping” a cube. Consider the above matrix in 3D (no W axis):

This truncated version shifts the X extent into the W dimension, but that dimension is cut off and not shown. The effect is that the X dimension reduces to zero (at 90°), restores in the negative (reversed) direction (at 180°), reduces to zero (at 270°), and finally restores positively (at 360°).

The matrix for 4D rotation around the X and Z axes:

Which is the tesseract rotation that seems to move the cubes along the Y-axis (the second mode of rotation seen in the video).

The matrix for 4D rotation around the X and Y axes:

Which is the tesseract rotation that seems to move cubes along the Z-axis (the third mode of rotation seen in the video below).

February 27th, 2019 at 8:53 am

And it works in comments, too:

May 7th, 2020 at 7:24 pm

Or my favorite, Schrodinger’s Equation:

November 20th, 2020 at 1:51 pm

I’ve seen the notion of naming the rotation matrix after the axes that change rather than the rotation axis. That would certainly make more sense with 2D matrices.

So, instead of R

_{z}, use R_{xy}.November 23rd, 2020 at 9:30 am

This page seems to be getting a number of hits lately. I wonder what people find so interesting.