I was first introduced to the concept of the fourth dimension watching Carl Sagan’s Cosmos as a child. When I first watched it, the concept was certainly a challenge, but the simple analogy that the two-dimensional beings could not perceive a third dimension (and therefore, nor could we perceive a fourth) always stuck with me.

Working with virtual reality I thought it might be interesting to extrapolate upon this concept. In reading about the fourth dimension, bizarre “hyper-objects” such as the tesseract come up. At first glance the object Carl Sagan is holding in the YouTube video above is nothing more than a cube with another cube inset within it, but upon further explanation we discover it is the 3-dimensional “shadow” of a tesseract hyper-cube. It’s certainly interesting, but does little to alter our perception of this invisible direction. But what if we see it in motion?

Watching this mesmerizing animation helps to understand just how different from a cube it is, and how interesting the concept of a fourth dimension can be, but we still lack any way to begin to sense this dimension. Perhaps if we started with ordinary objects, we could begin to grasp what existing in a fourth dimension might mean for them. Instead of trying to get our heads around this supposed projection from another place, why not manipulate a simple desk or chair in the fourth dimension?

If our reality does in fact include a fourth dimension (whether we can detect it or not) everything in that reality is inherently four-dimensional. Just as a seemingly two-dimensional sheet of paper occupies some very small sliver of a third-dimension, so might these objects occupy an infinitesimal region of the fourth dimension.

In order to better grasp this concept I read the novella which was likely the basis for Carl Sagan’s description of dimensional existence – *Flatland: a romance of many dimensions *by Edwin Abbott Abbott. Written in 1884 Much of the book is concerned with the culture and way of life in flatland, which at first seems dry and irrelevant, but after a while you find yourself immersed. The thorough description of this alternate reality frames ones thinking into that of a flat being, which makes the eventual revelation of the three-dimensional world far more convincing and magical. This really allows the reader to begin to extrapolate their imagination into a fourth dimension.

Perhaps the most interesting concept I took away from reading *Flatland *was the idea that a fourth dimension would expose the “insides” of any three-dimensional objects. Just like we and the sphere in *Flatland* can see inside two-dimensional objects, so too could a four-dimensional being see our insides, and so too would our innards be connected to an open, shared space.

I continued to delve into the possibilities… Any three-dimensional space (such as that we perceive) could exist parallel to a possibly infinite series of other three-dimensional spaces. Parallel universes stacked upon each-other like the pages of a book, with a fourth dimension binding them all together, would it be possible to turn a page? What about all of the perpendicular spaces that could exist? For example, if we occupy a space with dimensions X, Y, and Z, and we call the fourth dimension “W”, we could then have a total of four different arrangements of three-dimensional spaces, XYZ, WXY, WXZ, and WZY. Each shares its dimensions with the others, yet has its own unique, perpendicular configuration.

Finally, here is the finished product of all of this pondering…

I initially thought that this might be a good opportunity to give Unreal Engine a try. After finally getting everything set up I found myself staring blankly at an empty C++ script, quickly realizing I should leave learning a new workflow for another day.

The most interesting, yet likely simplest to implement manipulation would be a simple rotation like that seen in the tesseract animation. I knew that three-dimensional rotations could be accomplished using rotation matrices, and these were easy enough to find; however, four-dimensional rotations become somewhat more complicated, and everywhere I looked, I found only report after report on how to derive these matrices, (in a fundamental sense, not in a simple step by step explanation) and no actual matrices. Fortunately I came across two papers which together gave me enough of a hint as to what these matrices should look like: Erdogdu & Özdemiry’s “Generating Four Dimensional Rotation Matrices,” and John Ernest Mebius’s “The Four Dimensional Rotation Group SO(4).”

The key was thinking of rotations as happening in a plane, rather than about a particular axis. So rotating around the Z axis in 3D is really rotating in the XY plane. Knowing this there could be only 6 possible rotations in 4D: XY, XZ, YZ, WX, WY, WZ. In addition, more complex rotations could be accomplished by combining these simple rotations. The basic 3D rotations are, as usual:

I then derived the remaining matrices with reference to the aforementioned papers:

To make it more efficient I then combined these with 4D vectors to obtain the form that would be used in code.

And the resulting code:

//rotate about plane specified public Vector4 MeshRotFourXY(Vector4 i, float angle) { i.Set((i.x * Mathf.Cos(angle)) - (i.y * Mathf.Sin(angle)), (i.x * Mathf.Sin(angle)) + (i.y * Mathf.Cos(angle)), i.z, i.w); return i; } public Vector4 MeshRotFourXZ(Vector4 i, float angle) { i.Set((i.z * Mathf.Sin(angle)) + (i.x * Mathf.Cos(angle)), i.y, (i.z * Mathf.Cos(angle)) - (i.x * Mathf.Sin(angle)), i.w); return i; } public Vector4 MeshRotFourYZ(Vector4 i, float angle) { i.Set(i.x, (i.y * Mathf.Cos(angle)) - (i.z * Mathf.Sin(angle)), (i.y * Mathf.Sin(angle)) + (i.z * Mathf.Cos(angle)), i.w); return i; } public Vector4 MeshRotFourXW(Vector4 i, float angle) { i.Set((i.w * Mathf.Sin(angle)) + (i.x * Mathf.Cos(angle)), i.y, i.z, (i.w * Mathf.Cos(angle)) - (i.x * Mathf.Sin(angle))); return i; } public Vector4 MeshRotFourYW(Vector4 i, float angle) { i.Set(i.x, (i.w * Mathf.Sin(angle)) + (i.y * Mathf.Cos(angle)), i.z, (i.w * Mathf.Cos(angle)) - (i.y * Mathf.Sin(angle))); return i; } public Vector4 MeshRotFourZW(Vector4 i, float angle) { i.Set(i.x, i.y, (i.z * Mathf.Cos(angle)) - (i.w * Mathf.Sin(angle)), (i.z * Mathf.Sin(angle)) + (i.w * Mathf.Cos(angle))); return i; }

To make things more interesting I added the orthographic projection typical to 4D representations, effectively setting the scale between x, y, and z as a function of an element within w. I gave the viewer some control over this distance so the projection could be perceived as arbitrary. The base formula was found in this YouTube video by James Schloss:

Finally I added a second room which exists in a perpendicular 3D space (WYZ instead of XYZ), all of the objects in one room have a corresponding object in the other that oscillate in and out of existence as one trades its depth to the other. All manipulations are carried out in the mesh of the object, and their 4 dimensional coordinates are stored seperately in Vector4 arrays. One glitch that arises is that simulated rigidbody objects are liable to lose their collision mesh if they reach 0 thickness in any dimension causing them to disappear from existence, but this seems like a reasonable consequence for the careless manipulation of objects in and out of the fourth dimension. Mesh manipulation can be time-consuming, so I ran all such manipulations as co routines rather than directly in the update loop to minimize their effect on the frame rate.

I discovered a number of different four-dimensional experiences during my research, and . For me the biggest proof that we can think in abstract four-dimensional space was playing Huon Wilson’s 2048 4D – after getting used to thinking in this way it just makes sense! I found the original 2048 relatively foreign after mastering the task of manipulating numbers in four perpendicular directions.

Daniel Piker does a number of four-dimensional manipulations to ordinary objects:

And Wenbo Lan’s VR experience for the Vive focusing on manipulating four-dimensional hyper-objects. Seeing this video made me certain I could accomplish what I wanted to in Unity; however, I wanted to avoid the focus on these unfamiliar shapes.

#### Sources

Edwin Abbott Abbot, *Flatland: a romance of many dimensions*, (1884, 1953, Reprint; Princeton, NJ: Princeton University Press, 1991).

John Ernest Mebius, “The Four Dimensional Rotation Group SO(4),” pdf, accessed February 25, 2017, https://jemebius.home.xs4all.nl/so4-wiki.pdf.

Melek Erdogdu, Mustafa Özdemiry, “Generating Four Dimensional Rotation Matrices,” pdf, accessed February 25, 2017, https://www.researchgate.net/publication/283007638_Generating_Four_Dimensional_Rotation_Matrices.

Daniel Piker, “4-Dimensional Rotations,” *Space Symmetry Structure, *accessed February 25, 2017, https://spacesymmetrystructure.wordpress.com/2008/12/11/4-dimensional-rotations/.

Wenbo Lan, “Interacting with 4D Objects,” *Wenbolan.com*, accessed February 25, 2017, http://wenbolan.com/4dobject.html.

James Schloss, “fourth_dimension.py,” Python Script, accessed February 25, 2017, https://github.com/leios/simuleios/blob/master/visualization/fourth_dimension/fourth_dimension.py.