Rotating hypercube

Screen Saver

Hyper Screen Saver: Freeware for Windows

The Hyper screen saver dis­plays a rotat­ing 4-​dimen­sional object (hyper­cube or 4-​simplex) pro­jected onto 3-​space using a 4-D per­spec­tive trans­formation.

Notes

  • The axis of rota­tion (a plane) changes ran­domly after a few cycles un­less you press the H key (hold). Con­tinu­ing to press the H key tog­gles hold mode on and off.
  • Press C to change the plane of rota­tion at the com­ple­tion of the cur­rent rota­tion (even in hold mode).
  • Press the F key to speed up the 4-D rota­tion or S to slow it down.
  • Press U, D, R, or L to change the posi­tion of the light source.
  • Press 3 to toggle 3-D rota­tion on and off.
  • Press O to toggle opaque and wire-​frame rendering.
  • Pressing other keys tells the screen saver to terminate.

The screen saver funda­mentals were based on an exam­ple (minimal screen saver) pub­lished on­line by Lucian Wischik (www.wischik.com/scr/). The math of n-dimensional rota­tion, per­spective trans­for­ma­tion, and hid­den facet removal is my own work.

In 2009, I con­verted the original Hyper screen saver from Borland C++ to Micro­soft Visual C++ and cleaned up the code. In March 2010, I added the hyperbrick option. The Borland ver­sion is still here if you really want it (view page source), but I’ve been using only Micro­soft C++ in recent years.

File Description
Hyper-2010.zip Zipped file con­tain­ing the Hyper screen saver (2010 MSC version)

Remarks

When a rotating cube in 3 is pro­jected onto a 2-dimen­sional dis­play sur­face using a 3-D per­spec­tive trans­forma­tion, the facets that are farther away from the center of pro­jec­tion (CP) appear smaller than the facets that are closer. In a trans­par­ent wire-​frame render­ing, the back facets (squares) seem to shrink and pass through the front facets and then grow as they again become front facets. When shading and hidden-​surface removal are done, a facet dis­appears from view when­ever it faces away from the CP and re­appears when it rotates so that it faces the CP again.

Something similar happens when a rotat­ing hypercube in 4 is pro­jected down to 3 using a 4-D per­spec­tive trans­for­ma­tion. In a trans­par­ent render­ing, the back facets (which are 3-dimen­sional cubes in this case) shrink and pass through the front facets before start­ing to grow again. With shading and hidden-​facet removal, the facets appear and dis­appear (but the render­ing is com­plicated by the need to per­form another pro­jec­tion to map the 3-D image onto a 2-dimensional dis­play surface).

The animated GIF at the upper right corner of this page shows the rotating hypercube. Click­ing the image selects a dif­fer­ent ver­sion with a dif­fer­ent rota­tion plane (using Javascript).

Since I started experi­ment­ing with the hyperbrick shape (see below), I’ve decided I like it bet­ter than the sim­plex or the hypercube. I con­sidered a mono­lith à la 2001: A Space Odyssey (1 × 4 × 9 × 16), but I think using the golden ratio makes a more æs­theti­cally pleas­ing image.

Rotating hyper-brick

To-Do List

  • Finish test­ing on wide-​screen monitors.
  • Double rotation in 4? Since 4 is roomier than 3, two inde­pendent simple ro­ta­tions can occur simul­taneously at dif­fer­ent rates. How­ever, on the screen this double ro­ta­tion just looks like a 4-D ro­ta­tion of the ob­ject com­bined with a 3-D rota­tion of the pro­jected image.
  • Rewrite the program, making expli­cit use of geo­metric algebra? Using GA from the start would have sim­pli­fied the code and pro­moted better struc­ture. The exist­ing code is ugly.
Note: If you click the animated GIF file in the upper right corner of this page, it should change to another ver­sion with a dif­fer­ent rota­tion. As of 2014-12-28, the bug in Fire­fox that had often caused this opera­tion to fail seems to be fixed.