Takashi Yoshino

Rubiks cube has a natural extension to four-dimensional space. This article constructs the basic concepts of the puzzle and implements it in a program. The well-known three-dimensional Rubiks cube consists of 27 unit subcubes. Each face of determines a set of nine subcubes that have a face in the same plane as . The set can be rotated around the normal through the center of . Rubiks 4-cube (or 4D hypercube) consists of 81 unit 4-subcubes, each containing eight 3D subcubes. Each 3-face of determines a set of 27 4-subcubes that have a cube in the same hyperplane as . The set can be rotated around the normal (a plane) through the center of . Projecting the whole 4D configuration to 3D exhibits Rubiks 4-cube as a four-dimensional extension of Rubiks cube. Starting from a random coloring of the 4-cube, the goal of the puzzle is to return to the initial coloring of the 3-faces.

Basic Concepts

Hypercubes in Low Dimensions

To understand the 4D hypercube, it helps to first see how its lower-dimensional analogs relate to each other. The zero-dimensional hypercube (or 0-cube) is a point, with one vertex. The 1D hypercube (or 1-cube) is a segment, with two vertices and one edge. The 2D hypercube (or 2-cube) is a square, with four vertices, four edges and one face (the square including its interior). The 3D hypercube is a cube (or 3-cube), with eight vertices, edges, six square faces and one volume. Going up a dimension doubles the number of vertices. More generally, the number of -cubes (points, segments, squares, ) in an -cube, , is .

The 3D cube can be represented in a 2D plane using central projection, defined by taking the intersection of the plane with the line joining the two points and . This projection maps the point to . Choose to obtain the projection shown on the right in
Figure 1. Five of the faces overlap with a sixth face, the price to pay for the loss of one dimension.

Figure 1. A cube and its image under a central projection.

4-Cube

Overall, the 4D Rubik puzzle is a 4-cube [1] (or 4D hypercube or tesseract), with vertices, edges, squares, eight cubes and one 4-cube. The eight cubes are called cells, which are like the six square faces of a 3D cube. The proper faces of the 4-cube are its vertices, edges, squares and cells.

Each point of a proper face is on the 3D hypersurface of the 4-cube. No point of a proper face is strictly in the interior of the 4-cube; that is, a hypersphere at such a point contains points inside and points outside the 4-cube. In particular, no interior point of a cell as a 3D object is in the interior of the hypercube; all the points of a cell are on the boundary of the 4-cube.

The 16 vertices of a 4-cube can be defined as lists of length four of all possible combinations of
and .

The 24 squares of the 4-cube are described in terms of their vertex indices.

Besides the 4-cube, there are five other regular polytopes in four dimensions. The .csv and .m files containing information for these polytopes are provided at [2]: the positions of the vertices, vertex indices for the proper faces and which faces are neighbors.

To display the 4-cube in 3D, central projection from 4D to 3D is analogous to central projection from 3D to 2D; the function is the natural extension of ; see Figure 2.

Figure 2. Projected image of a 4-cube by means of center projection. The larger outer cube is one of the cells of the 4-cube.

Rotation

An axis of rotation in 3D is a fixed line. In 4D, an axis of rotation in four dimensions is a fixed plane [3]. For example, the rotation matrix about the plane is defined by:

(1)

There are six planes of rotation spanned by pairs of coordinate axes, namely , , , , , .

Here is the first one, for example, which leaves points in the plane fixed.

This animation shows two successive rotations of the 4-cube projected to 3D.

Implementing Rubiks 4-Cube

Dividing the 4-Cube

Consider a 4-cube with center at the origin , side length 3, and with all proper faces of positive dimension parallel to the coordinate axes. Then its 16 vertices are:

(2)

The eight cells of the initial 4-cube are colored differently. The word initial means that no rotations have been applied. The coloring touches every point of a cell, including its 3D interior points.

Just as the faces of Rubiks cube are divided into nine squares by dividing each edge into three, the edges of Rubiks 4-cube are also divided into three. Then the initial 4-cube is divided into small 4-cubes, each with edge length 1. The boundary (a hypersurface) of a small 4-cube contains eight small cubes, its cells.

The Rubik 3-cube has 27 subcubes in ; no square of the center cube is colored and some squares of other cubes are colored. These 26 subcubes are classified into three types according to whether they are at a corner, at an edge or at the center of a face of the larger cube. Figure 3 shows one of each type.

Figure 3. Three types of small cubes: in the center of a square face, at an edge and at a vertex, with one, two or three colored squares.

Analogously, the 81 small 4-cubes of include the uncolored one at the center and 80 partially colored small 4-cubes. These are classified into four types according to the dimension of their intersection with . The type of a small 4-cube does not change after rotation. Table 1 summarizes the numbers for each type for and .

Table 1. Numbers of colored small squares for and small cubes for for each type of small
cube or cell.

The number of colored small squares for Rubiks cube is calculated using the data in Table 1:

Another way is to count the number of faces times the number of squares per face: .

The small 4-cubes with nonzero coordinates form the hypersurface of . In particular, a small 4-cube with center given by four nonzero coordinates contains a vertex of . Again from Table 1, the number of colored small cells is:

This number can also be obtained as the number of cells of times the number of small cells per cell of : .

We define several global variables to be used here and later. Figure 4 shows the divided 4-cube with 216 colored small cells.

Figure 4. Center projection of a hypercube consisting of 216 colored small cells.

Each edge is divided into three parts, so that the length of the 4-subcubes is 1. Consider a 4-subcube with center at . Then, the vertices of the 4-subcube are . The coordinates of the center of each 4-subcube are a combination of one of , 0 and . When the value is nonzero ( or ), the 4-subcubes face outward in the corresponding directions. In other words, the nonzero values in coordinates denote the outward-facing 4-subcubes.

The 216 Colored Small Cells and Initial State

For the initial state, the colors of the cells are set according to the coordinates of their centers:

For example, in the small 4-cube with center , the two small cells with vertices and are colored because both the and coordinate values are nonzero.

The geometry of the 216 small colored cells is used to manage the puzzle. Each element of the datasets consists of four elements: (1) the vertices of six squares; (2) the location of the center of the small 4-cube to which the small cell belongs; (3) color; and (4) the location of the center of the small cell. The vertices of the six squares are used for drawing the subcubes, and the locations of the centers of the subcubes are used to judge the completeness of the puzzle. The dataset of the initial state is obtained by the following procedures. First, the vertex numbers of the squares making up each small cell are defined.

Next, the 216 small cells are selected by checking all possible small cells.

This list contains 216 entries and each entry contains four components corresponding to a small cell.

For example, here is entry 123 of . The components for this small cell are its six square faces, center, color and current position.

sets up a 4-cube for drawing.

Here is an example.

sets up a cell (with 27 4-cubes) for drawing.

Figure 5 shows the initial state of Rubiks 4-cube.

Figure 5. Center projection of initial state of the Rubik 4-cube with its eight cells.

In the 3D case of Rubiks cube , a block is a set of nine small cubes whose centers have one coordinate that is constant, , 0 or 1. There are nine blocks, three per coordinate axis. A natural technique to rotate a middle block, for example, the one cut by the plane by , is to rotate the block above by , the block below by , and then the whole cube by .

In the 4D case, a block is a set of 27 small 4-cubes whose centers have one coordinate that is constant. There are 12 blocks, four per axis and three per choice of constant coordinate , 0 or 1. Under a rotation, the small 4-cubes in a block change position simultaneously. Each block is a four-dimensional hyperprism with height 1.

Figure 6 shows an example of the block ; the cell opposite the orange cell is not colored.

Figure 6. Example of a block of 27 small 4-cubes (orange, ).

A block is rotated by , or around an axis, which is a fixed plane. Therefore, the information needed for an action on the Rubik 4-cube is (1) the block to be rotated; (2) the axis of rotation; and (3) the angle. For Rubiks cube , the axis of rotation is automatically determined by selecting a block. But for , two coordinate axes must be chosen to determine the fixed plane. One is the constant coordinate axis used to select the block, and the other must be chosen from the remaining three coordinate axes. There are 108 possible actions on : 12 choices of block, three choices for the second coordinate axis and three choices of angle: . Therefore, 108 buttons are required for the rotations in the Rubik 4-cube computer program. Table 2 lists the properties of Rubiks cube and Rubiks 4-cube.

Table 2. Properties of Rubiks cube and Rubiks 4-cube.

Final Form

The program to realize Rubiks 4-cube in 3D relies on central projection of a hypercube and rotation matrices in 4D. The program is shown in the next section.

Implementing an interface consists of three parts: constructing the buttons for the rotations, displaying the current state and judging whether the puzzle is complete.

The buttons for the rotations are placed in grids. The player can rotate a block by clicking one of the buttons. The rows correspond to the selection of the axis of the coordinates of the block and the columns correspond to the coordinate values for that axis. The player can select a block by choosing one of the rows and one of the columns. For example, clicking the button where row crosses column chooses the block on . For each block, the other three axes are listed. Then, the selection of the second axis is required to verify the rotational plane. Finally, one of the three buttons (up, diagonal and down) must be chosen to determine the rotation angle of (), () and (). (The 0 rows can be ignoredthe player can perform an equivalent pair of actions instead in the parallel blocks.)

When the colors of the 27 subcubes on a cell are all the same, that cell is complete. The puzzle is solved when all the cells are complete.

Program

Discussion

Although we succeeded in implementing Rubiks 4-cube, some problems remain to be addressed. We aimed for ease of implementation rather than efficiency. Therefore, in the future, we should consider enhancing the application to get a more effective visualization method and an intuitive interface.

The program redraws 1,296 squares after each rotation, so that efficient coding is important. There is a great deal of redundancy in calculating the vertices of the 4-subcubes for each rotation. The most effective method for handling the vertices using subcubes or 4-subcubes remains to be clarified. Note that we must transfer the vertices of the 4-subcubes to those of the subcubes when we handle the vertices of 4-subcubes as a dataset rather than handling them as subcubes.

Effective visualization is a common problem for four-dimensional geometry. In this article, we used central projection to represent 4-cubes. However, the proposed projection does not completely represent the features of the puzzle. Although there are other projections for representing a 4-cube, the most suitable method is not yet clear.

Another possible improvement would be to animate the rotation. The animation of the rotation of the colored small 4-cubes would help the player intuitively understand their rearrangement.

An intuitive interface is important for playing this puzzle. The interface and visualization issues are related, and their development may provide a new method for understanding four-dimensional space.

References

[1] H. S. M. Coxeter, Introduction to Geometry, 2nd ed., Hoboken: Wiley, 1989.
[2] T. Yoshino. Activities of Dr. Takashi Yoshino. (Dec 11, 2017)
takashiyoshino.random-walk.org/basic-data-of-4d-regular-polytopes.
[3] K. Miyazaki, M. Ishii and S. Yamaguchi, Science of Higher-Dimensional Shape and Symmetry, Kyoto: Kyoto University Press, 2005 (In Japanese).
T. Yoshino, Rubiks 4-Cube, The Mathematica Journal, 2017. dx.doi.org/doi:10.3888/tmj.19-8.

About the Author

Profession: Science of Form. Fields of interest: skeletal structure of plankton, non-Euclidean geometry, hyperspace, pattern formation.

Takashi Yoshino
Toyo University,
Kujirai 2100, Kawagoe, 350-8585, JAPAN
tyoshino@toyo.jp