Man has been fascinated about the possibility of there being more than three dimensions ever since he has understood the concept. Henry More (1614-1687) considered that spirits have four dimensions.H.G. Wells suggested that the fourth dimension is time in The Time Machine. This can be misleading in fact since time is somewhat different from the other three dimensions as we know them. Abbott's Flatland (1) is probably nearer the mark. He considers the life of a 2-dimensional square which suddenly has the chance to travel in three dimensions. This gives the square the ability to see inside objects in its 2-dimensional world, something it previously thought was impossible. Using this analogy from three to four dimensions, we would be able to see inside solid objects if we were able to break out of our own 3-dimensional world into the fourth dimension. Taking the analogy further, when a 3-dimensional object crosses a 2-dimensional world its inhabitants simply see an object appear from nowhere, grow in size, changing its shape in a rather odd manner if the object is irregular, and then decrease in size until it disappears again. In our world this would be the equivalent of an object suddenly appearing somewhere, growing in size, shrinking and then disappearing without trace. This may soung very disturbing but this is because we do not fully understand the fourth dimension.
What is a dimension? We may define a dimension as being a direction which is at right angles to any other dimension. In our world we simply run out of directions after we have defined three dimensions (length, width and height for example). However there is no reason why there should be anything special about three dimensions apart from the fact that we live in a 3-dimensional world. Thinking in terms of three dimensions is simply of the most practical use to us. We are quite willing to project 3-dimensional objects into two dimensions when we draw or photograph them. Again this because it is useful to us (e.g. an architect's plan of a house). There is no reason why we may not project objects of more than three dimensions. Note that in this case we also have the choice of projecting them into three dimensions if we wish. Probably the simplest and most interesting objects to consider for projection are polytopes. These are geometrical figures bounded by portions of lines, planes or hyperplanes (for polytopes of 2, 3 and 4 or more dimensions respectively). In two dimensions the polytope is known as a polygon and in three dimensions it is known as a polyhedron. For simplicity we shall restrict ourselves to regular polytopes in which all the vertices, edges, faces, etc. are the same. In two dimensions these consist of the equilateral triangle, square, etc. There are an infinite number of these. In three dimensions there are only five such solids known as the Platonic polyhedra which were discovered by the ancient Greeks. These are the tetrahedron, cube, octahedron, dodecahedron and icosahedron. A complete description of these and many other polyhedra may be found in Mathematical Models by Cundy and Rollett(2). In four dimensions there are six such polytopes, five of which may be considered as the four dimensional equivalents of the Platonic polyhedra. These are described in Coxeter's Regular Polytopes (3). In fact it turns out that the tetrahedron, cube and octahedron have similar equivalents in any number of dimensions. A simple algorithm may be used to generate the polytope for the next dimension up in each case (3). These may be projected in two dimensions. The cube was chosen out of the other two possiblities since this produces more interesting projections having square rather than triangular sides. However the reader may be interested in investigating the other two himself. For those interested in more complicated polytopes, Coxeter's Regular Complex Polytopes (4) is recommended.
A cube of N dimensions may be generated from a cube of (N-1) dimensions in the following manner. Take the (N-1)-dimensional cube and redraw it displaced along a new dimension by a distance equal to the length of one of its sides. Now join the corresponding vertices of each of the old cubes and the new cube is formed. This may be demonstrated by starting with a "cube" of zero dimensions. This consists of a single point as would any 0-dimensional object. Displace this point along any dimension by a given distance (say a distance L from the origin along the X-axis - seefigure 1.1). We now have a line of length L (a 1-dimensional cube). Next displace this line a distance L along a new dimension (say the Y-axis) and join the corresponding ends (see figure 1.2). We have now formed a square, a 2-dimensional cube. Now along the Z-axis, join the corresponding corners and we form the standard 3-dimensional cube (see figure 1.3). If we displace the cube along a new axis (say the W-axis) and join the corresponding vertices we form what is generally known as a hyper-cube or 4-dimensional cube (see figure 1.4). We may now continue this process as many times as we wish to form a multi-dimensional cube of any given number of dimensions.
The program listed infigure 2 draws N-dimensional cubes. It was written to run on a Research Machines 380Z microcomputer with high resolution graphics but could be adapted to run on any computer with BASIC and a line plotting facility of some sort. The number of dimensions that can be plotted is limited by the resolution of the plotting device. Above about 8 dimensions the cube becomes too complex to be viewed on the Research Machines screen. Other systems may be able to plot more or less dimensions than this. Below 3 dimensions the "cube" is no longer a true cube. The program draws the cubes symmetrically so that above about 4 dimensions some very pretty and interesting patterns are produced (see figures 3.1 to 3.7).
First the desired number of dimensions is read into the variable
Nin line 170. Lines 260 to 400 initialise the arrays
Y1. These contain the coordinate offsets necessary to plot each possible direction of the cube's sides. Lines 410 to 520 calculate the origin coordinates (
Y0) and the size factor (
F). Line 530 positions the origin. The
FORloop from lines 540 to 830 calculates the start and finish positions of each edge of the cube and draws a line between them. Arrays
I2contain flags (with values of 0 or 1) which are used to indicate which coordinate offsets are to be used for the beginning and end coordinates of each edge plotted. Lines 610 to 660 calculate the starting position and line 670 positions the current coordinates at that position. Lines 680 to 730 calculate the end position and line 740 draws a line to that position. Finally the program loops back to line 90, displays the number of dimensions of the cube (line 140) and prompts the user for a new value of
N. The program may then be rerun if desired or terminated by typing a carriage return on a blank line.
The following lines contain special calls and commands to control graphics on the Research Machines 380Z and will need to be changed for other systems:
Y0and F (the coordinates of the new origin and the size factor) will probably need to be adjusted (i.e. lines 410 to 520 will have to be changed as necessary). Line 670 moves the current position to the coordinates (
Y). (In fact it also draws a point at that position but this is not necessary for the program to work.) Line 740 draws a line from the current position to a new position at coordinates (
4.0*ATN(1.0). Apart from the points noted above the program is written in "standard" BASIC and there should be few problems transfering the program to another computer with the necessary hardware and software graphics capabilities.
Acknowledgement: The above plots were generated using a Java program which is accessible on-line, written by Andy Wallace.
Z W . . . . . . . . . . . .. .__________. . . . X . . . . . . Y
Z W . . . . . . . . . . . .. .__________. . . . X / / / / / / /__________/ . . Y
Z W . . . . .__________ . /| /| . / | / | / | / | /__________/ | | .| | | | |______|___| . . . X | / | / | / | / |/ |/ |__________| . . Y
Z . W . . __________ . /|\ . /|\ ./ | \ . / | \ /. | \ . / | \ /__________/ | \ |\ | \_|\_______\ | \ |____/||_\_| /| | \/\ / || \ \ / | | /\ \/ || / \ \/ | | / \/_________\/\ | |/____|___|| | \ | \ | \|_\____|__\| . . . X \ | / \ | / \ | / \ | / \ |/ \ |/ \|_________\| . . Y
Jonathan Bowen10 REM N-dimensional cube program to 20 REM run on Research Machines 380Z 30 REM with high resolution graphics. 40 REM Written by
,50 REM Imperial College
, London SW7 2AZ.60 REM Date 22-Oct-81 70 REM COPYRIGHT (C) 1981 J.P.BOWEN 80 DIM X1(10),Y1(10),I1(10),I2(10) 90 GRAPH 1 100 PRINT 110 IF N>0 THEN 140
120 PRINT "N-dimensional cube program" 130GOTO 150
140 PRINT TAB(8);N;"dimensional cube" 150 PRINT 160 PRINT 170 INPUT "Enter no of dimensions (2-10)";N 180 CALL "RESOLUTION",0,1 190 IF N>1 THEN250
200 PRINT 210 PRINT 220 PRINT "End of cube program" 230 GRAPH 0 240 END 250 IF N>10 THEN170
260 P=3.14159/N 270 I=-1 280FOR J=1 TO N STEP 2
290 I=I+1 300 C=I*P 310 X1(J)=COS(C) 320 Y1(J)=SIN(C) 330NEXT J
340 I=N 350FOR J=2 TO N STEP 2
360 I=I-1 370 C=I*P 380 X1(J)=COS(C) 390 Y1(J)=SIN(C) 400NEXT J
410 F=0 420FOR J=1 TO N
430 F=F+Y1(J) 440NEXT J
450 X0=0 460FOR J=1 TO N
470 IF X1(J)<0 THENhttp://www.cs.reading.ac.uk/people/jpb/publications/ndcubes.html#Line-
X0=X0+X1(J) 480 I1(J)=0 490NEXT J
500 F=190/F 510 X0=X0-40/F 520 Y0=0 530 CALL "OFFSET",X0*F,Y0*F 540FOR I=1 TO 2^N-1
550FOR J=1 TO N
560 I2(J)=I1(J) 570NEXT J
580FOR J=1 TO N
590 IF I1(J)=1 THEN760
600 I2(J)=1 610 X=0 620 Y=0 630FOR K=1 TO N
640 X=X+I1(K)*X1(K) 650 Y=Y+I1(K)*Y1(K) 660NEXT K
670 CALL "PLOT",X*F,Y*F 680 X=0 690 Y=0 700FOR K=1 TO N
710 X=X+I2(K)*X1(K) 720 Y=Y+I2(K)*Y1(K) 730NEXT K
740 CALL "LINE",X*F,Y*F 750 I2(J)=0 760NEXT J
770 J=1 780 IF I1(J)=0 THEN820
790 I1(J)=0 800 J=J+1 810GOTO 780
820 I1(J)=1 830NEXT I
Originally published as "Hypercubes" in Practical Computing, 5(4), pp 97-99, April 1982.