About a month ago I had to rest up at home following a medical emergency, and I was looking for a way to distract myself which wasn't getting stuck on the harder levels of Baba Is You or reading Boswell's Life of Johnson (which was good, but sometimes too gloomy).

I've been interested in visualising four-dimensional shapes for a while now, and earlier this year I read Coxeter's Regular Polytopes, and probably understood a third of it. I decided to try and write a little web toy using the Javascript GL framework three.js to visualise the six regular polytopes: these are the 4D analogues of the Platonic solids.

Getting the six shapes working wasn't too hard: the various Wikipedia pages for the six solids have coordinates for their vertices, and once I'd built those, deriving the edges was a matter of picking the nearest neighbours to each vertex. If you're not interested in more of the details you can go straight to the end result: FourJS.

After I'd written the first version (I was still home sick at this point) I decided that it would be nice to colour the vertices of each shape in some kind of pleasingly symmetrical way. I worked out colour schemes for the 5-cell, 16-cell, tesseract and 24-cell quickly, and after a bit of research, I found a transcription (in a paper on quantum physics) of the Dutch geometer Schoute's partition of the 120 vertices of the 600-cell.

The way these partitions work is by what's called "inscription": to take a simple example, the eight vertices of a cube are also the vertices of two tetrahedra, the edges of which are the diagonals of the cube's faces. These two tetrahedra are said to be inscribed in the cube. In a similar way, the vertices of polytopes can be partitions into groups which form the vertices of simpler polytopes. Schoute's partition divides the 120 vertices of the 600-cell into five 24-cells (in two different ways).

Finding a partition of the 600 vertices of the 120-cell was the real challenge. I found a few references which told me that five 600-cells could be inscribed in the 120-cell, which would give five groups of vertices, but no convenient reference for how those vertices were arranged. I tried a couple of amateurish approaches to writing an algorithm which failed, and then found a comment on Stack Exchange which gave me the key.

Five tetrahedra can be inscribed in a dodecahedron: this pattern is quite beautiful in its own right. If one partitions the twenty vertices of each of the dodecahedra in the 120-cell following this pattern, making sure that the patterns match at the adjoining faces where the dodecahedra meet, and that the chirality is correct (because there are two ways to partition them) the resulting five sets of 120-cell vertices are the vertices of the five inscribed 600-cells. I'm not mathematician enough to prove this, but the resulting colouring is internally consistent and looks nice.

A 3D projection of the 120-cell with its vertices coloured

It's possible to render all five 600-cells inscribed in the 120-cell, but even the following image, which shows just one of the inscribed 600-cells, is pretty indecipherable.

A 3D projection of the 120-cell with its vertices coloured and an inscribed 600-cell

You can play with the different polytopes here: FourJS and the source code is on GitHub. The code which generates the partition is still very rough and I'm planning a more detailed writeup once I've had a bit of a break from dreaming about dodecahedra.