What is a Tesseract? Cybercube - the first step into the fourth dimension

τέσσαρες ἀκτίνες - four beams) - 4-dimensional hypercube- analogue in 4-dimensional space.

The image is a projection () of a four-dimensional cube onto a three-dimensional space.

The generalization of a cube to cases with more than 3 dimensions is called hypercube or (en:measure polytopes). Formally, a hypercube is defined as four equal segments.

This article mainly describes the 4-dimensional hypercube, called tesseract.

Popular Description

Let's try to imagine what the hypercube will look like without leaving our three-dimensional .

In one-dimensional "space" - on a line - we select AB of length L. On a two-dimensional "space" at a distance L from AB, we draw a segment DC parallel to it and connect their ends. Get the square ABCD. Repeating this operation with a plane, we get a three-dimensional cube ABCDHEFG. And by shifting the cube in the fourth dimension (perpendicular to the first three!) by a distance L, we get a hypercube.

The one-dimensional segment AB serves as a face of the two-dimensional square ABCD, the square is the side of the cube ABCDHEFG, 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.

In a similar way, we can continue the reasoning for hypercubes of a larger number of dimensions, but it is much more interesting to see how for us, inhabitants of three-dimensional space, it will look like four-dimensional hypercube. 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 fourth dimension. 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. Its part, which remained in “our” space, is drawn with solid lines, and the part that went into hyperspace is dashed. 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 eight faces of a three-dimensional cube, you can decompose it into a flat figure - a net. 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 of geometric figures of lower dimension into 4-dimensional space, presented in the following table.

Teachings about multidimensional spaces began to appear in the middle of the 19th century. Science fiction borrowed the idea of ​​four-dimensional space from scientists. In their works, they told the world about the amazing wonders of the 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. Surgeons performed operations on internal organs without cutting the tissue of the patient's body.

tesseract

In geometry, a hypercube is an n-dimensional analogy of a square (n = 2) and a cube (n = 3). The four-dimensional analogue of our usual 3-dimensional cube is known as the 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 polyhedron whose boundary consists of eight cubic cells.


Each pair of non-parallel 3D faces intersect to form 2D faces (squares), and so on. Finally, a tesseract has 8 3D faces, 24 2D, 32 edges and 16 vertices.
Incidentally, 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 tetra - four) - a four-dimensional cube.



Construction and description

Let's try to imagine how the hypercube will look without leaving the 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.

In a similar way, we can continue the reasoning for hypercubes of a larger number of dimensions, but it is much more interesting to see how a four-dimensional hypercube will look like for us, inhabitants of three-dimensional space.

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 can be divided into 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, you can decompose it into a flat figure - a net. 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".



Hypercube in art

The Tesseract is such an interesting figure that it has repeatedly attracted the attention of writers and filmmakers.
Robert E. Heinlein mentioned hypercubes several times. In The House That Teal Built (1940), he described a house built as an unfolding of a tesseract, and then, due to an earthquake, "formed" in the fourth dimension and became a "real" tesseract. In the novel Glory Road by Heinlein, a hyperdimensional box is described that was larger on the inside than on the outside.

Henry Kuttner's story "All Borog's Tenals" describes an educational toy for children from the distant future, similar in structure to a tesseract.

The plot of Cube 2: Hypercube centers on eight strangers trapped in a "hypercube", or network of connected cubes.

A parallel world

Mathematical abstractions brought to life the idea of ​​the existence of parallel worlds. These are realities that exist simultaneously with ours, but independently of it. The parallel world can have different sizes: from a small geographical area to the whole universe. In a parallel world, events take place in their own way, it may differ from our world, both in individual details and in almost everything. At the same time, the physical laws of the parallel world are not necessarily similar to the laws of our Universe.

This topic is fertile ground for science fiction writers.

The Crucifixion on the Cross by Salvador Dali depicts a tesseract. "Crucifixion or Hypercubic Body" - a painting by the Spanish artist Salvador Dali, written in 1954. Depicts the crucified Jesus Christ on the development of the tesseract. The painting is kept at the Metropolitan Museum of Art in New York.

It all started in 1895, when HG Wells discovered the existence of parallel worlds for fantasy with the story "The Door in the Wall". In 1923, Wells returned to the idea of ​​parallel worlds and placed in one of them a utopian country where the characters of the novel "People Are Like Gods" go.

The novel did not go unnoticed. In 1926, G. Dent's story "The Emperor of the Country" If "" appeared. In Dent's story, for the first time, the idea arose that there could be countries (worlds) whose history could go differently from the history of real countries in our world. And worlds these are no less real than ours.

In 1944, Jorge Luis Borges published the short story "The Garden of Forking Paths" in his book Fictional Stories. Here the idea of ​​the branching of time was finally expressed with the utmost clarity.
Despite the appearance of the works listed above, the idea of ​​many worlds began to develop seriously in science fiction only at the end of the forties of the XX century, approximately at the same time when a similar idea arose in physics.

One of the pioneers of a new direction in science fiction was John Bixby, who suggested in the story "One-Way Street" (1954) that between the worlds you can move only in one direction - having gone from your world to a parallel one, you will not return back, but you will move from one world to the next. However, returning to your own world is also not excluded - for this it is necessary that the system of worlds be closed.

Clifford Simak's novel Ring Around the Sun (1982) describes numerous planets of the Earth, each existing in its own world, but in the same orbit, and these worlds and these planets differ from each other only by a slight (by a microsecond) shift in time . Numerous Earths visited by the hero of the novel form a single system of worlds.

A curious look at the branching of the worlds was expressed by Alfred Bester in the story "The Man Who Killed Mohammed" (1958). “Changing the past,” the hero of the story claimed, “you change it only for yourself.” In other words, after changing the past, a branch of history arises, in which only for the character who made the change, this change exists.

In the story of the Strugatsky brothers "Monday begins on Saturday" (1962), the characters' journeys to different variants described by science fiction writers of the future - in contrast to the travels in science fiction that already existed in various options of the past.

However, even a simple enumeration of all the works that deal with the theme of the parallelism of the worlds would take too much time. And although science fiction writers, as a rule, do not scientifically substantiate the postulate of multidimensionality, they are right in one thing - this is a hypothesis that has the right to exist.
The fourth dimension of the tesseract is still waiting for us to visit.

Viktor Savinov


If you're a fan of the Avengers movies, the first thing that comes to your mind when you hear the word "Tesseract" is the transparent cube-shaped vessel of the Infinity Stone that contains limitless power.

For fans of the Marvel Universe, the Tesseract is a glowing blue cube that people from not only Earth, but other planets also go crazy about. That's why all the Avengers have banded together to protect the Grounders from the extremely destructive forces of the Tesseract.

What needs to be said, however, is this: A tesseract is an actual geometric concept, more specifically, a shape that exists in 4D. It's not just a blue cube from The Avengers... it's a real concept.

A tesseract is an object in 4 dimensions. But before we explain it in detail, let's start from the beginning.

What is a "measurement"?

Everyone has heard the terms 2D and 3D, representing respectively two-dimensional or three-dimensional objects of space. But what are these measurements?

A dimension is simply a direction you can go. For example, if you are drawing a line on a piece of paper, you can either go left/right (x-axis) or up/down (y-axis). So we say the paper is two-dimensional since you can only walk in two directions.

There is a sense of depth in 3D.

Now, in real world, besides the two directions mentioned above (left/right and up/down), you can also go "in/out". Consequently, a sense of depth is added in 3D space. Therefore we say that real life 3-dimensional.

A point can represent 0 dimensions (because it doesn't move in any direction), a line represents 1 dimension (length), a square represents 2 dimensions (length and width), and a cube represents 3 dimensions (length, width and height).

Take a 3D cube and replace each face (which is currently a square) with a cube. And so! The shape you get is the tesseract.

What is a tesseract?

Simply put, a tesseract is a cube in 4-dimensional space. You can also say that this is the 4D equivalent of a cube. This is a 4D shape where each face is a cube.

A 3D projection of a tesseract performing a double rotation around two orthogonal planes.
Image: Jason Hise

Here's a simple way to conceptualize dimensions: a square is two-dimensional; so each of its corners has 2 lines extending from it at 90 degrees to each other. The cube is 3D, so each of its corners has 3 lines coming off of it. Likewise, the tesseract is a 4D shape, so each corner has 4 lines extending from it.

Why is it difficult to imagine a tesseract?

Since we as humans have evolved to render objects in three dimensions, anything that goes into extra dimensions like 4D, 5D, 6D, etc. doesn't make much sense to us because we can't visualize them at all. introduce. Our brain cannot understand the 4th dimension in space. We just can't think about it.

However, just because we can't visualize the concept of multidimensional spaces doesn't mean it can't exist.

A universe of four dimensions, or four coordinates, is just as unsatisfactory as three. It can be said that we do not have all the data necessary to build the universe, since neither the three coordinates of the old physics, nor the four coordinates of the new one are sufficient to describe, Total variety of phenomena in the universe.

Consider in order the "cubes" of various dimensions.

A one-dimensional cube on a straight line is a segment. Two-dimensional - a square. The border of the square consists of four points - peaks And four segments - ribs. Thus, a square has two types of elements on its boundary: points and segments. The boundary of a three-dimensional cube contains elements of three types: vertices - there are 8 of them, edges (segments) - there are 12 of them and faces (squares) - there are 6 of them. The one-dimensional segment AB serves as the face of the two-dimensional square ABCD, the square is the side of the cube ABCDHEFG, which, in turn, will be the side of the four-dimensional hypercube.

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.

Cube dimension

Border Dimension

2 square

4 tesseract

Coordinates infour-dimensional space.

A point on a straight line is defined as a number, a point on a plane as a pair of numbers, a point in three-dimensional space as a triple of numbers. Therefore, it is quite natural to construct the geometry of a four-dimensional space by defining a point of this imaginary space as a four of numbers.

A two-dimensional face of a four-dimensional cube is a set of points for which two of any coordinates can take on various values ​​from 0 to 1, and the other two are constant (equal to either 0 or 1).

3D face A four-dimensional cube is a set of points for which three coordinates take on all possible values ​​from 0 to 1, and one is constant (equal to either 0 or 1).

Development of cubes of various dimensions.

We take a segment, place a segment on all sides, and attach one more to any, in this case, to the right segment.

We got a square scan.

We take a square, place a square on all sides, attach one more to any, in this case, to the lower square.

This is a 3D cube.

four dimensional cube

We take a cube, place a cube on all sides, attach one more to any, in the given lower cube.

Unfolding a 4D Cube

Imagine that a four-dimensional cube is made of wire and an ant sits at the vertex (1;1;1;1), then the ant will have to crawl along the edges from one vertex to another.

Question: how many edges will he have to crawl to get to the vertex (0;0;0;0)?

Along 4 edges, that is, the vertex (0; 0; 0; 0) is a vertex of the 4th order, passing along 1 edge it can get to a vertex that has one of the coordinates 0, this is a vertex of the 1st order, passing along 2 edges it can get to vertices where there are 2 zeros, these are vertices of the 2nd order, there are 6 such vertices, passing along 3 edges, it will fall into vertices with 3 coordinates zero, these are vertices of the third order.

There are other cubes in multidimensional space. In addition to the tesseract, you can build cubes with a large number measurements. The model of a five-dimensional cube is the penteract. The penteract has 32 vertices, 80 edges, 80 faces, 40 cubes and 10 tesseracts.

Artists, directors, sculptors, scientists represent the multidimensional cube in different ways. Here are some examples:

Many science fiction writers describe the tesseract in their works. For example, Robert Anson Heinlein (1907–1988) mentioned hypercubes in at least three of his non-fiction stories. In The House of Four Dimensions, he described a house built as an unfolding of a tesseract.

The plot of Cube 2 centers on eight strangers trapped in a hypercube.

« Crucifixion" by Salvador Dali 1954 (1951). Dali's surrealism was looking for points of contact between our reality and the other world, in particular, the 4-dimensional world. Therefore, on the one hand, it is amazing, and, on the other hand, there is nothing surprising in the fact that geometric figure of cubes, forming a Christian cross, is an image of a 3-dimensional sweep of a 4-dimensional cube or tesseract.

On October 21, an unusual sculpture called the Octacub was unveiled at the Pennsylvania State University Mathematics Department. It is an image of a four-dimensional geometric object in three-dimensional space. According to the author of the sculpture, Professor Adrian Okneanu, such a beautiful figure of this kind did not exist in the world, either virtually or physically, although three-dimensional projections of four-dimensional figures were made before.

In general, mathematicians easily operate with four-, five- and even more multidimensional objects, but it is impossible to depict them in three-dimensional space. The Octacub, like all such figures, is not truly four-dimensional. It can be compared with a map - a projection of a three-dimensional surface the globe on a flat sheet of paper.

A three-dimensional projection of a four-dimensional figure was obtained by Oknean using the method of radial stereography using a computer. At the same time, the symmetry of the original four-dimensional figure was preserved. The sculpture has 24 vertices and 96 faces. In four-dimensional space, the faces of the figure are straight, but in projection they are curved. The angles between the faces of the three-dimensional projection and the original figure are the same.

The Octacube was made from stainless steel in the Pennsylvania State University engineering workshops. The sculpture was installed in the renovated building named after McAllister of the Faculty of Mathematics.

Multidimensional space was of interest to many scientists, such as Rene Descartes, Hermann Minkowski. Nowadays, there is an increase in knowledge on this topic. It helps mathematicians, researchers and inventors of our time to achieve their goals and advance science. A step into multidimensional space is a step into a new, more advanced era of humanity.

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 you make a parallel translation of 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 a given plane, using the vanishing point, you need to draw a straight 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 a 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, small and large, 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 left of the small square, are in fact 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 they 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" (the point to be projected), and ptp` is the 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 a better idea of ​​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.

If you find an error, please select a piece of text and press Ctrl+Enter.