4 dimensional cube rotation. For everyone and everything

Even when I was a first-year student, I had a heated argument with one of my classmates. He said that a four-dimensional cube could not be represented in any form, and I assured that it could be represented quite clearly. Then I even made a projection of a hypercube onto our three-dimensional space out of paper clips... But let's talk about everything in order.
What is a hypercube (tesseract) and four-dimensional space
There are three dimensions in our habitual space. With geometric point of view, this means that three mutually perpendicular lines can be indicated in it. That is, for any line, you can find a second line perpendicular to the first, and for a pair, you can find a third line perpendicular to the first two. It will no longer be possible to find the fourth straight line perpendicular to the three existing ones.

Four-dimensional space differs from ours only in that it has one more additional direction. If you already have three mutually perpendicular lines, then you can find the fourth one, such that it will be perpendicular to all three.
A hypercube is just a cube in four dimensions.
Is it possible to imagine a four-dimensional space and a hypercube?
This question is similar to the question: "can you imagine Last Supper looking at the painting of the same name (1495-1498) by Leonardo da Vinci (1452-1519)?”
On the one hand, of course, you will not imagine what Jesus saw (he is sitting facing the viewer), especially since you will not smell the garden outside the window and the taste of food on the table, you will not hear the birds singing ... You will not get full view about what happened that evening, but it cannot be said that you will not learn anything new and that the picture is of no interest.
The situation is similar with the question of the hypercube. It is impossible to fully imagine it, but you can get closer to understanding what it is.

Space-time and Euclidean four-dimensional space
I hope you managed to imagine the hypercube. But have you managed to get closer to understanding how the four-dimensional space-time in which we live works? Alas, not really.
Here we talked about Euclidean four-dimensional space, but space-time has very different properties. In particular, at any rotation, the segments always remain inclined to the time axis, either at an angle less than 45 degrees, or at an angle greater than 45 degrees.

Projections and vision of an inhabitant of four-dimensional space
A few words about vision
We live in a three-dimensional world, but we see it as two-dimensional. This is due to the fact that the retina of our eyes is located in a plane that has only two dimensions. That is why we are able to perceive two-dimensional pictures and find them similar to reality. (Of course, thanks to accommodation, the eye can estimate the distance to an object, but this is already a side effect associated with the optics built into our eye.)
The eyes of an inhabitant of four-dimensional space must have a three-dimensional retina. Such a creature can immediately see a three-dimensional figure completely: all its faces and insides. (In the same way, we can see a two-dimensional figure, all its faces and insides.)
Thus, with the help of our organs of vision, we are not able to perceive a four-dimensional cube in the same way as an inhabitant of a four-dimensional space would perceive it. Alas. It remains only to rely on the mind's eye and fantasy, which, fortunately, have no physical limitations.
However, when depicting a hypercube on a plane, I simply have to project it onto two-dimensional space. Keep this in mind when studying drawings.
Edge intersections
Naturally, the edges of the hypercube do not intersect. Intersections appear only in figures. However, this should not come as a surprise, because the edges of an ordinary cube in the figures also intersect.
Rib lengths
It is worth noting that all faces and edges of a four-dimensional cube are equal. In the figure, they are not equal only because they are located under different angles to the direction of view. However, it is possible to unfold the hypercube so that all projections have the same length.

Tesseract - a four-dimensional hypercube - a cube in four-dimensional space.
According to the Oxford Dictionary, the word tesseract was coined and used in 1888 by Charles Howard Hinton (1853-1907) in his book " new era thoughts". Later, some people called the same figure a tetracube (Greek τετρα - four) - a four-dimensional cube.
An ordinary tesseract in Euclidean four-dimensional space is defined as the convex hull of points (±1, ±1, ±1, ±1). In other words, it can be represented as the following set:
[-1, 1]^4 = ((x_1,x_2,x_3,x_4) : -1 = A tesseract is bounded by eight hyperplanes x_i= +- 1, i=1,2,3,4 , whose intersection with the tesseract itself defines it 3D faces (which are regular cubes) Each pair of non-parallel 3D faces intersect to form 2D faces (squares), etc. Finally, the tesseract has 8 3D faces, 24 2D, 32 edges, and 16 vertices.
Popular Description
Let's try to imagine what the hypercube will look like without leaving three-dimensional space.
In one-dimensional "space" - on a line - we select a segment AB of length L. On a two-dimensional plane at a distance L from AB, we draw a segment DC parallel to it and connect their ends. You will get a square CDBA. Repeating this operation with a plane, we get a three-dimensional cube CDBAGHFE. And by shifting the cube in the fourth dimension (perpendicular to the first three) by a distance L, we get the CDBAGHFEKLJIOPNM hypercube.
The one-dimensional segment AB serves as a side of the two-dimensional square CDBA, the square is the side of the cube CDBAGHFE, which, in turn, will be the side of the four-dimensional hypercube. A straight line segment has two boundary points, a square has four vertices, and a cube has eight. Thus, in a four-dimensional hypercube, there will be 16 vertices: 8 vertices of the original cube and 8 vertices shifted in the fourth dimension. It has 32 edges - 12 each give the initial and final positions of the original cube, and 8 more edges "draw" eight of its vertices that have moved into the fourth dimension. The same reasoning can be done for the faces of the hypercube. In two-dimensional space, it is one (the square itself), the cube has 6 of them (two faces from the moved square and four more will describe its sides). A four-dimensional hypercube has 24 square faces - 12 squares of the original cube in two positions and 12 squares from twelve of its edges.
As the sides of a square are 4 one-dimensional segments, and the sides (faces) of a cube are 6 two-dimensional squares, so for the “four-dimensional cube” (tesseract) the sides are 8 three-dimensional cubes. The spaces of opposite pairs of tesseract cubes (that is, the three-dimensional spaces to which these cubes belong) are parallel. In the figure, these are cubes: CDBAGHFE and KLJIOPNM, CDBAKLJI and GHFEOPNM, EFBAMNJI and GHDCOPLK, CKIAGOME and DLJBHPNF.
Similarly, we can continue the reasoning for hypercubes more dimensions, but it is much more interesting to see how a four-dimensional hypercube will look like for us, the inhabitants of three-dimensional space. Let us use for this the already familiar method of analogies.
Let's take the wire cube ABCDHEFG and look at it with one eye from the side of the face. We will see and can draw two squares on the plane (its near and far faces), connected by four lines - side edges. Similarly, a four-dimensional hypercube in three-dimensional space will look like two cubic "boxes" inserted into each other and connected by eight edges. In this case, the "boxes" themselves - three-dimensional faces - will be projected onto "our" space, and the lines connecting them will stretch in the direction of the fourth axis. You can also try to imagine a cube not in projection, but in a spatial image.
Just as a three-dimensional cube is formed by a square shifted by the length of a face, a cube shifted into the fourth dimension will form a hypercube. It is limited by eight cubes, which in the future will look like some rather complex figure. The four-dimensional hypercube itself consists of an infinite number of cubes, just as a three-dimensional cube can be “cut” into an infinite number of flat squares.
By cutting six faces of a three-dimensional cube, one can decompose it into flat figure- a sweep. It will have a square on each side of the original face, plus one more - the face opposite to it. A three-dimensional development of a four-dimensional hypercube will consist of the original cube, six cubes that "grow" from it, plus one more - the final "hyperface".
The properties of the tesseract are an extension of the properties geometric shapes lower dimension into a four-dimensional space.

In geometry hypercube- This n-dimensional analogy of a square ( n= 2) and cube ( n= 3). This is a closed convex figure, consisting of groups of parallel lines located on opposite edges of the figure, and connected to each other at right angles.

This figure is also known as tesseract(tesseract). The tesseract is to the cube as the cube is to the square. More formally, a tesseract can be described as a regular convex four-dimensional polytope (polytope) whose boundary consists of eight cubic cells.

According to the Oxford English Dictionary, the word "tesseract" was coined in 1888 by Charles Howard Hinton and used in his book A New Era of Thought. The word was formed from the Greek "τεσσερες ακτινες" ("four rays"), is in the form of four coordinate axes. In addition, in some sources, the same figure was called tetracube(tetracube).

n-dimensional hypercube is also called n-cube.

A point is a hypercube of dimension 0. If you shift a point by a unit of length, you get a segment of unit length - a hypercube of dimension 1. Further, if you shift a segment by a unit of length in a direction perpendicular to the direction of the segment, you get a cube - a hypercube of dimension 2. Shifting the square by a unit of length in the direction perpendicular to the plane of the square, a cube is obtained - a hypercube of dimension 3. This process can be generalized to any number of dimensions. For example, if you shift a cube by a unit of length in the fourth dimension, you get a tesseract.

The family of hypercubes is one of the few regular polyhedra that can be represented in any dimension.

Hypercube elements

Dimension hypercube n has 2 n"sides" (one-dimensional line has 2 points; two-dimensional square - 4 sides; three-dimensional cube - 6 faces; four-dimensional tesseract - 8 cells). The number of vertices (points) of the hypercube is 2 n(for example, for a cube - 2 3 vertices).

Quantity m-dimensional hypercubes on the boundary n-cube equals

For example, on the border of a hypercube there are 8 cubes, 24 squares, 32 edges and 16 vertices.

Elements of hypercubes
n-cube Name Vertex
(0-face)
Edge
(1-face)
edge
(2-face)
Cell
(3-face)
(4-face) (5-face) (6-face) (7-face) (8-face)
0-cube Dot 1
1-cube Line segment 2 1
2-cube Square 4 4 1
3-cube Cube 8 12 6 1
4-cube tesseract 16 32 24 8 1
5-cube Penteract 32 80 80 40 10 1
6-cube Hexeract 64 192 240 160 60 12 1
7-cube Hepteract 128 448 672 560 280 84 14 1
8-cube Octeract 256 1024 1792 1792 1120 448 112 16 1
9-cube Eneneract 512 2304 4608 5376 4032 2016 672 144 18

Plane projection

The formation of a hypercube can be represented in the following way:

  • Two points A and B can be connected to form line segment AB.
  • Two parallel segment AB and CD can be connected to form the square ABCD.
  • Two parallel squares ABCD and EFGH can be joined to form the cube ABCDEFGH.
  • Two parallel cubes ABCDEFGH and IJKLMNOP can be connected to form a hypercube ABCDEFGHIJKLMNOP.

The latter structure is not easy to imagine, but it is possible to depict its projection onto two or three dimensions. Moreover, projections onto a 2D plane can be more useful by rearranging the positions of the projected vertices. In this case, images can be obtained that no longer reflect the spatial relationships of the elements within the tesseract, but illustrate the structure of the vertex connections, as in the examples below.

The first illustration shows how a tesseract is formed in principle by joining two cubes. This scheme is similar to the scheme for creating a cube from two squares. The second diagram shows that all the edges of the tesseract have the same length. This scheme is also forced to look for cubes connected to each other. In the third diagram, the vertices of the tesseract are located in accordance with the distances along the faces relative to the bottom point. This scheme is interesting in that it is used as basic circuit for the network topology of connecting processors in organizing parallel computing: the distance between any two nodes does not exceed 4 edge lengths, and there are many different ways to balance the load.

Hypercube in art

The hypercube has appeared in science fiction since 1940, when Robert Heinlein, in the story "The House That Teal Built" ("And He Built a Crooked House"), described a house built in the shape of a tesseract unfold. In the story, this Further, this house is folded up, turning into a four-dimensional tesseract. After that, the hypercube appears in many books and novels.

Cube 2: Hypercube is about eight people trapped in a network of hypercubes.

The painting Crucifixion (Corpus Hypercubus), 1954 by Salvador Dali depicts Jesus crucified on a tesseract scan. This painting can be seen in the Museum of Art (Metropolitan Museum of Art) in New York.

Conclusion

The hypercube is one of the simplest four-dimensional objects, on the example of which you can see all the complexity and unusualness fourth dimension. And what looks impossible in three dimensions is possible in four, for example, impossible figures. So, for example, the bars of an impossible triangle in four dimensions will be connected at right angles. And this figure will look like this from all viewpoints, and will not be distorted, unlike the implementations of the impossible triangle in three-dimensional space (see Fig.

Teachings about multidimensional spaces started to appear in mid-nineteenth century in the works of G. Grassmann, A. Cayley, B. Riemann, W. Clifford, L. Schläfli and other mathematicians. At the beginning of the 20th century, with the advent of A. Einstein's theory of relativity and the ideas of G. Minkowski, physics began to use a four-dimensional space-time coordinate system.

Then science fiction writers borrowed the idea of ​​four-dimensional space from scientists. In their works they told the world about amazing miracles fourth dimension. The heroes of their works, using the properties of four-dimensional space, could eat the contents of the egg without damaging the shell, drink a drink without opening the cork of the bottle. The kidnappers retrieved the treasure from the safe through the fourth dimension. The links of the chain can be easily disconnected, and the knot on the rope can be untied without touching its ends. Surgeons performed operations on internal organs without cutting the tissue of the patient's body. The mystics placed the souls of the dead in the fourth dimension. For ordinary person the idea of ​​a four-dimensional space has remained incomprehensible and mysterious, and many generally consider four-dimensional space to be the fruit of the imagination of scientists and science fiction writers, which has nothing to do with reality.

Perception problem

It is traditionally believed that a person cannot perceive and represent four-dimensional figures, since he is a three-dimensional being. The subject perceives three-dimensional figures with the help of the retina, which is two-dimensional. To perceive four-dimensional figures, a three-dimensional retina is needed, but a person does not have such an opportunity.

To get a visual representation of four-dimensional figures, we will use analogies from spaces of lower dimension for extrapolation to figures of higher dimension, use the modeling method, apply methods system analysis to search for patterns between elements of four-dimensional figures. The proposed models should adequately describe the properties of four-dimensional figures, do not contradict each other and give a sufficient idea of ​​a four-dimensional figure and, first of all, of its geometric shape. Since there is no systematic and visual description of four-dimensional figures in the literature, but only their names indicating some properties, we propose to start the study of four-dimensional figures with the simplest - four-dimensional cube, which is called a hypercube.

Hypercube definition

hypercubea regular polytope is called, the cell of which is a cube.

Polytop is a four-dimensional figure, the boundary of which consists of polyhedra. An analogue of a cell of a polytope is a face of a polyhedron. The hypercube is analogous to a three-dimensional cube.

We will have an idea about the hypercube if we know its properties. The subject perceives some object, representing it in the form of some model. Let's use this method and present the idea of ​​a hypercube in the form of various models.

Analytical model

We will consider a one-dimensional space (straight line) as an ordered set of pointsM(x), where x- coordinate arbitrary point straight. Then the unit segment is given by specifying two points:A(0) and B(1).

A plane (two-dimensional space) can be viewed as an ordered set of points M(x; y). The unit square will be completely defined by its four vertices: A(0; 0), B(1; 0), C(1; 1), D(0; 1). The coordinates of the vertices of the square are obtained by adding zero to the coordinates of the segment, and then one.

Three-dimensional space - an ordered set of points M(x; y; z). Eight points are required to define a 3D cube:

A(0; 0; 0), B(1; 0; 0), C(1; 1; 0), D(0; 1; 0),

E(0; 0; 1), F(1; 0; 1), G(1; 1; 1), H(0; 1; 1).

The cube coordinates are obtained from the square coordinates by adding zero and then one.

Four-dimensional space is an ordered set of points M(x; y; z; t). To specify a hypercube, you need to determine the coordinates of its sixteen vertices:

A(0; 0; 0; 0), B(1; 0; 0; 0), C(1; 1; 0; 0), D(0; 1; 0; 0),

E(0; 0; 1; 0), F(1; 0; 1; 0), G(1; 1; 1; 0), H(0; 1; 1; 0),

K(0; 0; 0; 1), L(1; 0; 0; 1), M(1; 1; 0; 1), N(0; 1; 0; 1),

O(0; 0; 1; 1), P(1; 0; 1; 1), R(1; 1; 1; 1), S(0; 1; 1; 1).

The hypercube coordinates are obtained from the coordinates of the 3D cube by adding a fourth coordinate, zero, and then unity.

Using formulas analytical geometry for a four-dimensional Euclidean space, one can obtain the properties of a hypercube.
As an example, consider the calculation of the length of the main diagonal of a hypercube. Let it be required to find the distance between points A(0, 0, 0, 0) and R(1, 1, 1, 1). To do this, we use the distance formula in four-dimensional Euclidean space.

In two-dimensional space (on a plane), the distance between points A(x 1 , y 1) and B(x 2 , y 2) is calculated by the formula

This formula follows from the Pythagorean theorem.

The corresponding formula for the distance between points A(x 1 , y 1 , z 1) and B(x 2 , y 2 , z 2) in three-dimensional space has the form

And in one-dimensional space (on a straight line) between points A( x 1) and B( x 2) you can write the corresponding distance formula:

Similarly, the distance between points A(x 1 , y 1 , z 1 , t 1) and B(x 2 , y 2 , z 2 , t 2) in four-dimensional space will be calculated by the formula:

For the proposed example, we find

Thus, the hypercube exists analytically, and its properties can be described no worse than the properties of a three-dimensional cube.

Dynamic Model

The analytical model of the hypercube is very abstract, so let's consider another model - the dynamic one.

A point (a zero-dimensional figure), moving in one direction, generates a segment (a one-dimensional figure). The segment, moving in a direction perpendicular to itself, creates a square (two-dimensional figure). The square, moving in a direction perpendicular to the plane of the square, creates a cube (three-dimensional figure).

The cube, moving perpendicular to the three-dimensional space in which it was originally located, generates a hypercube (four-dimensional figure).

The hypercube boundary is three-dimensional, finite and closed. It consists of a three-dimensional cube in home position, a three-dimensional cube in its final position, and six cubes formed by moving the squares of the original cube in the direction of the fourth dimension. The entire boundary of the hypercube consists of 8 three-dimensional cubes (cells).

When moving in the initial position, the cube had 8 vertices and in the final position also 8 vertices. Therefore, the hypercube has total 16 peaks.

Four mutually perpendicular edges emanate from each vertex. In total, the hypercube has 32 edges. In the initial position, it had 12 edges, in the final position also 12 edges, and 8 edges formed the tops of the cube when moving in the fourth dimension.

Thus, the border of the hypercube consists of 8 cubes, which consist of 24 squares. Namely, 6 squares in the initial position, 6 in the final position, and 12 squares formed by moving 12 edges in the direction of the fourth dimension.

geometric model

The dynamic model of a hypercube may seem insufficiently clear. Therefore, consider the geometric model of the hypercube. How do we get the geometric model of a 3D cube? We unfold it, and from the unfold we “glue” the cube model. The development of a three-dimensional cube consists of a square, to the sides of which is attached a square plus one more square. We turn adjacent squares around the sides of the square, and connect the adjacent sides of the squares to each other. And we close the remaining four sides with the last square (Fig. 1).

Similarly, consider the unfolding of the hypercube. Its development will be a three-dimensional figure, consisting of the original three-dimensional cube, six cubes adjacent to each face of the original cube, and one more cube. There are eight three-dimensional cubes in total (Fig. 2). In order to obtain a four-dimensional cube (hypercube) from this development, each of the adjacent cubes must be rotated by 90 degrees. These adjoining cubes will be located in a different 3D space. Connect adjacent faces (squares) of cubes to each other. Embed the eighth cube with its faces into the remaining unfilled space. We get a four-dimensional figure - a hypercube, the boundary of which consists of eight three-dimensional cubes.

Hypercube image

It was shown above how to “glue” a hypercube model from a three-dimensional scan. We get images using projection. The central projection of a three-dimensional cube (its image on a plane) looks like this (Fig. 3). Inside the square is another square. The corresponding vertices of the square are connected by segments. Adjacent squares are depicted as trapezoids, although they are squares in 3D space. The inner and outer squares are different sizes, but in real 3D space they are equal squares.

Similarly, the central projection of a four-dimensional cube onto three-dimensional space will look like this: inside one cube is another cube. The corresponding vertices of the cubes are connected by segments. The inner and outer cubes have different sizes in three dimensions, but in four dimensions it is equal cubes(Fig. 4).

Six truncated pyramids are images of equal six cells (cubes) of a four-dimensional cube.

This three-dimensional projection can be drawn on a plane and you can verify the truth of the properties of the hypercube obtained using the dynamic model.

The hypercube has 16 vertices, 32 edges, 24 faces (squares), 8 cells (cubes). Four mutually perpendicular edges emanate from each vertex. The boundary of the hypercube is a three-dimensional closed convex figure, the volume of which (the side volume of the hypercube) is equal to eight unit three-dimensional cubes. Inside itself, this figure contains a unit hypercube, the hypervolume of which is equal to the hypervolume of the unit hypercube.

Conclusion

In this work, the goal was to give an initial acquaintance with four-dimensional space. This was done on the example of the simplest figure - the hypercube.

The world of four-dimensional space is amazing! In it, along with similar figures in three-dimensional space, there are also figures that have no analogues in three-dimensional space.

Many phenomena material world, the macrocosm and the megaworld, despite the grandiose successes in physics, chemistry and astronomy, have remained inexplicable.

Not unified theory that explains all the forces of nature. There is no satisfactory model of the Universe that explains its structure and excludes paradoxes.

By knowing the properties of four-dimensional space and borrowing some ideas from four-dimensional geometry, it will be possible not only to build more rigorous theories and models of the material world, but also to create tools and systems that function according to the laws of the four-dimensional world, then human capabilities will be even more impressive.

Let's start by explaining what a four-dimensional space is.

This is a one-dimensional space, that is, simply the OX axis. Any point on it is characterized by one coordinate.


Now let's draw the OY axis perpendicular to the OX axis. So we got a two-dimensional space, that is, the XOY plane. Any point on it is characterized by two coordinates - the abscissa and the ordinate.


Let's draw the OZ axis perpendicular to the axes OX and OY. You will get a three-dimensional space in which any point has an abscissa, an ordinate and an applicate.


It is logical that the fourth axis, OQ, should be perpendicular to the axes OX, OY and OZ at the same time. But we cannot accurately construct such an axis, and therefore it remains only to try to imagine it. Every point in four-dimensional space has four coordinates: x, y, z and q.

Now let's see how the four-dimensional cube appeared.


The picture shows a figure of one-dimensional space - a line.


If done parallel transfer this line along the OY axis, and then connect the corresponding ends of the two resulting lines, you get a square.


Similarly, if we make a parallel translation of the square along the OZ axis and connect the corresponding vertices, we get a cube.


And if we make a parallel translation of the cube along the OQ axis and connect the vertices of these two cubes, then we will get a four-dimensional cube. By the way, it's called tesseract.

To draw a cube on a plane, you need it project. Visually it looks like this:

Imagine that in the air above the surface hangs wireframe model cube, that is, as if "made of wire", and above it - a light bulb. If you turn on the light bulb, trace the shadow of the cube with a pencil, and then turn off the light bulb, then a projection of the cube will be shown on the surface.

Let's move on to something a little more complicated. Look again at the drawing with the light bulb: as you can see, all the rays converged at one point. It is called vanishing point and is used to build perspective projection(and sometimes parallel, when all the rays are parallel to each other. The result is that there is no sense of volume, but it is lighter, and if the vanishing point is far enough away from the projected object, then the difference between these two projections is hardly noticeable). To project given point on the given plane, using the vanishing point, you need to draw a line through the vanishing point and the given point, and then find the intersection point of the resulting line and the plane. And in order to project more complex figure, say, a cube, you need to project each of its vertices, and then connect the corresponding points. It should be noted that space-to-subspace projection algorithm can be generalized to 4D->3D, not just 3D->2D.

As I said, we can't imagine exactly what the OQ axis looks like, and neither can the tesseract. But we can get a limited idea of ​​it if we project it onto a volume and then draw it on a computer screen!

Now let's talk about the projection of the tesseract.


On the left is the projection of the cube onto the plane, and on the right is the tesseract onto the volume. They are quite similar: the projection of a cube looks like two squares, a small one and a large one, one inside the other, with corresponding vertices connected by lines. And the projection of the tesseract looks like two cubes, small and large, one inside the other, and whose corresponding vertices are connected. But we have all seen the cube, and we can say with confidence that both the small square and the large one, and the four trapezoids above, below, to the right and to the left of small square, in fact, are squares, moreover, they are equal. The same goes for the Tesseract. And a big cube, and a small cube, and six truncated pyramids on the sides of a small cube - these are all cubes, and they are equal.

My program can not only draw the projection of the tesseract onto the volume, but also rotate it. Let's see how this is done.

First, I'll tell you what is rotation parallel to the plane.

Imagine that the cube rotates around the OZ axis. Then each of its vertices describes a circle around the OZ axis.

A circle is a flat figure. And the planes of each of these circles are parallel to each other, and in this case are parallel to the XOY plane. That is, we can talk not only about rotation around the OZ axis, but also about rotation parallel to the XOY plane. As you can see, for points that rotate parallel to the XOY axis, only the abscissa and ordinate change, while the applicate remains unchanged And, in fact, we we can talk about rotation around a straight line only when we are dealing with three-dimensional space. In 2D everything revolves around a point, in 4D everything revolves around a plane, in 5D space we are talking about rotation around a volume. And if we can imagine the rotation around a point, then the rotation around the plane and volume is something unthinkable. And if we talk about rotation parallel to the plane, then in any n-dimensional space a point can rotate parallel to the plane.

Many of you have probably heard of the rotation matrix. Multiplying a point by it, we get a point rotated parallel to the plane by an angle phi. For a two-dimensional space, it looks like this:

How to multiply: x of a point rotated by an angle phi = cosine of the angle phi*x of the original point minus the sine of the angle phi*y of the original point;
y of the point rotated by the angle phi=sine of the angle phi*x of the original point plus cosine of the angle phi*y of the original point.
Xa`=cosФ*Xa - sinФ*Ya
Ya`=sinФ*Xa + cosФ*Ya
, where Xa and Ya are the abscissa and ordinate of the point to be rotated, Xa` and Ya` are the abscissa and ordinate of the already rotated point

For a three-dimensional space, this matrix is ​​generalized as follows:

Rotation parallel to the XOY plane. As you can see, the Z coordinate does not change, but only X and Y change.
Xa`=cosФ*Xa - sinФ*Ya + Za*0
Ya`=sinФ*Xa + cosФ*Ya + Za*0
Za`=Xa*0 + Ya*0 + Za*1 (essentially Za`=Za)


Rotation parallel to the XOZ plane. Nothing new,
Xa`=cosФ*Xa + Ya*0 - sinФ*Za
Ya`=Xa*0 + Ya*1 + Za*0 (in fact, Ya`=Ya)
Za`=sinФ*Xa + Ya*0 + cosФ*Za


And the third matrix.
Xa`=Xa*1 + Ya*0 + Za*0 (essentially Xa`=Xa)
Ya`=Xa*0 + cosФ*Ya - sinФ*Za
Za`=Xa*0 + sinФ*Ya + cosФ*Za

And for the fourth dimension, they look like this:


I think you already understood what to multiply by, so I won’t paint it again. But I note that it does the same as the matrix for rotating parallel to the plane in three-dimensional space! Both that and this one change only the ordinate and the applicate, and the rest of the coordinates are not touched, therefore it can be used in the three-dimensional case, simply ignoring the fourth coordinate.

But with the projection formula, not everything is so simple. No matter how much I read the forums, none of the projection methods suited me. Parallel did not suit me, since the projection will not look three-dimensional. In some projection formulas, to find a point, you need to solve a system of equations (and I don’t know how to teach a computer to solve them), I simply didn’t understand others ... In general, I decided to come up with my own way. Consider for this the projection 2D->1D.


pov means "Point of view" (point of view), ptp means "Point to project" (point to be projected), and ptp` is desired point on the OX axis.

Angles povptpB and ptpptp`A are equal as corresponding (dashed line is parallel to axis OX, line povptp is secant).
The x of ptp` is equal to the x of ptp minus the length of segment ptp`A. This segment can be found from the triangle ptpptp`A: ptp`A = ptpA/tangent of angle ptpptp`A. We can find this tangent from triangle povptpB: tangent of angle ptpptp`A = (Ypov-Yptp)(Xpov-Xptp).
Answer: Xptp`=Xptp-Yptp/tangent of angle ptpptp`A.

I did not describe this algorithm in detail here, since there are a lot of special cases where the formula changes somewhat. Who cares - look in the source code of the program, everything is written in the comments.

In order to project a point in three-dimensional space onto a plane, we simply consider two planes - XOZ and YOZ, and solve this problem for each of them. In the case of a four-dimensional space, it is necessary to consider already three planes: XOQ, YOQ and ZOQ.

And finally, about the program. It works like this: initialize sixteen vertices of the tesseract -> depending on the commands entered by the user, rotate it -> project onto the volume -> depending on the commands entered by the user, rotate its projection -> project onto a plane -> draw.

Projections and rotations I wrote myself. They work according to the formulas that I just described. The OpenGL library draws lines and also mixes colors. And the coordinates of the vertices of the tesseract are calculated in this way:

Line vertex coordinates centered at the origin and length 2 - (1) and (-1);
- "-" - a square - "-" - and an edge of length 2:
(1; 1), (-1; 1), (1; -1) and (-1; -1);
- " - " - cube - " - " -:
(1; 1; 1), (-1; 1; 1), (1; -1; 1), (-1; -1; 1), (1; 1; -1), (-1; 1; -1), (1; -1; -1), (-1; -1; -1);
As you can see, the square is one line above the OY axis and one line below the OY axis; a cube is one square in front of the XOY plane, and one behind it; a tesseract is one cube on the other side of the XOYZ volume, and one on this side. But it is much easier to perceive this alternation of units and minus units if they are written in a column

1; 1; 1
-1; 1; 1
1; -1; 1
-1; -1; 1
1; 1; -1
-1; 1; -1
1; -1; -1
-1; -1; -1

In the first column, one and minus one alternate. In the second column, first there are two pluses, then two minuses. In the third - four plus one, and then four minus one. These were the tops of the cube. The tesseract has twice as many of them, and therefore it was necessary to write a cycle for declaring them, otherwise it is very easy to get confused.

My program also knows how to draw anaglyph. Happy owners of 3D glasses can watch a stereoscopic picture. There is nothing tricky in drawing a picture, it just draws two projections on a plane, for the right and left eyes. But the program becomes much more visual and interesting, and most importantly - gives best performance about the four-dimensional world.

Less significant functions - highlighting one of the faces in red, so that you can better see the turns, as well as minor conveniences - adjusting the coordinates of the "eye" points, increasing and decreasing the speed of rotation.

Archive with the program, source code and instructions for use.