# How many MIT students does it take to figure out how to rotate a cube? by Andi Q. '25

(More than I’m proud to admit)

“@Andi you know how with ultra hand you can rotate objects in 45 degree increments?” my friend Fatema asked me over Discord one day, “how many unique [orientations] can you make?”

I was, for better or worse, all too familiar with this “ultra hand”. You see, I’d spent way too much of my free time last summer holed up in my room playing the new Legend of Zelda game instead of exploring New York City like a normal college student. For those of you who haven’t played the game yet01 I highly recommend it! Definitely my favourite game from this year , Ultrahand is one of the many new abilities our hero Link gains in his quest to defeat Ganondorf. At a high level, it allows him to lift, rotate, and fuse objects telekinetically.

Although this ability seems rather mundane at first glance, it allows the player to build some really crazy contraptions – from amphibious vehicles for traversing Hyrule to full-on attack drones that mow down hordes of enemies in seconds. And the fact that you can build functional mechanical computers in this game fills my engineering heart with so much joy.

Yet despite all the hours I’d sunk into the game, I’d never really thought about how the ability works beneath the hood. I mean, it’s just moving and rotating things around, right? I move objects around all the time – how complicated can it get?

# It gets quite complicated indeed

First, let’s talk about how the game handles rotations… or rather, how I initially *thought* it handled them. When using Ultrahand, you can rotate an object around two axes of rotation – left-right and up-down, each in 45-degree increments. To describe an object’s orientation, you needed just two things – the direction it faces and the relative rotation angle around that direction.

Sounds pretty straightforward, right? In fact, if rotations were in 90-degree increments instead, this model would accurately answer Fatema’s question – 6 directions (one for each face of a cube) times 4 relative rotation angles for 24 total unique orientations.

So I figured there were… maybe 64 independent directions (a factor of 8 from each axis)… times the 8 relative rotation angles for each direction… but also divided by 2 because we double count some orientations, which gives us…

“256,” I guessed, “final answer.”

Satisfied, I closed Discord and returned to my psets. Another day, another video game mystery answered with the infallible power of mathematics. MatPat would surely be proud. But no sooner had I picked up my pencil than I heard a notification ping from my laptop. Looking up, I saw that Fatema had replied with a link to a 2017 Mathematics Stack Exchange post.

“It says here that there are actually infinitely many orientations,” she objected.

My calculations had failed me! But why?

# Linear algebra to the… rescue?

TL;DR, rotations in 3D are weird because linear algebra is weird. Suppose you rotated a cube 45 degrees up→down→right→left. Where does it face after those rotations?

It faces the same way it started, intuitively because up→down and right→left rotations cancel each other out. But what if you rotated it 45 degrees up→**right**→**down**→left?

Uh-oh, it faces a slightly different direction now. So what happened, and why don’t the rotations cancel each other out anymore? To explain this discrepancy, we need to talk a bit about linear algebra.

A common way to describe a rotation in 3D is with a matrix – a 3×3 grid of numbers you can multiply with a direction (specified by a list of 3 numbers) to get another direction. A sequence of rotations is then equivalent to multiplying the corresponding rotation matrices in order.

It turns out that unlike multiplying numbers (where the order of multiplication doesn’t matter), matrix multiplication does (usually) depend on the order of multiplication02 This non-commutativity is actually one of the reasons why we have Heisenberg's Uncertainty Principle in quantum mechanics! ! And this key difference is why our cube faces a different direction when we change the order of rotations.

The Stack Exchange post that Fatema sent goes even further and proves that rotating the cube up→right→up→right→… (by 45 degrees each time) will never return it to its original orientation. Each intermediate orientation is unique, so there are infinitely many unique orientations. (In fact, it’s possible to achieve *any* possible orientation in 3D using up, right, down, and left rotations by 45 degrees! But in true MIT fashion, I leave the proof as an exercise to the reader.)

So there you go – a mathematical proof that rotations by 45 degrees should yield infinitely many unique orientations. Case closed; nothing more to see here.

… yet despite having this evidence in front of us, the result still didn’t sit well with Fatema or me. We’d spent enough time playing the game to know we didn’t have to rotate each object hundreds of times to achieve the desired orientation. There must be something else going on here! But where do you turn to when linear algebra fails you?

# Crystallography to the rescue!

Admittedly, this problem stumped us for a while. We tried a few other things, like using lines of latitude/longitude, but those didn’t work either. Then one day, while doing my 3.03303 Electronic, optical, and magnetic properties of materials pset, I had an idea – materials scientists deal a lot with crystals and their rotations in 3D, so maybe one of them knows how to solve this problem. Coincidentally, one of my good friends is a TA for 3.01004 I bet she can rotate cubes omnidirectionally in her head – the Course 3 (materials science and engineering) crystallography class.

“Hey Maria,” I messaged her, “you know how with ultra hand you can…”

A few minutes after describing the problem and our approaches thus far, I received a response:

“Isn’t this just crystallographic directions?”

I was slightly skeptical that the solution was that simple, but the more I thought about it, the more it made sense. For context, materials scientists use integer triples to describe directions inside crystals; Maria was referring to the 26 directions consisting of only ±1s and 0s.

This model perfectly described what I was used to seeing in-game – high symmetry and a discrete set of orientations. The key difference from my original model is that rotations are no longer done strictly in 45-degree increments, which was completely unexpected for me.

To verify this hypothesis, Fatema and I set up a little in-game experiment where we tried to see if a sequence of up→right→up→right→… rotations would bring an object back to its original orientation. And indeed, it did!

So in total, there are 26 possible directions and 8 relative rotation angles for each direction, giving us **2****08 unique orientations**. Not too far off from, my original guess of 256, but it’s pretty remarkable how this relatively small difference arose from such a profound misunderstanding of how the system works!

- I highly recommend it! Definitely my favourite game from this year back to text ↑
- This non-commutativity is actually one of the reasons why we have Heisenberg's Uncertainty Principle in quantum mechanics! back to text ↑
- Electronic, optical, and magnetic properties of materials back to text ↑
- I bet she can rotate cubes omnidirectionally in her head back to text ↑