Engee documentation
Notebook

Construction of the Silasi polyhedron (Silahedron)

In this demo example, we consider the construction of a Silashi polyhedron using the function mesh3d() from the library Plots.jl.

Introduction

Силаэдр is a nonconvex toroidal polyhedron for which the following equality holds from the Euler-Poincare characteristic

where - the number of faces of the polyhedron, and - the number of holes of the surface in which it is embedded.
This equality follows from the condition that in such a polyhedron each face has a common edge with any other face.

The sylahedron has 7 hexagonal faces, 14 vertices, and 21 edges. In the example, we will construct this polyhedron in the Cartesian coordinate system based on the available coordinates of the vertices.

Coordinates of the vertices

To begin with, we will introduce notation for faces and vertices. Vertices have consecutive numerical designations from 0 to 13, pairwise congruent faces have consecutive alphanumeric designations: A1, A2, B1, B2, B1, B2, and an unpaired face has the letter designation G.
The corresponding symbols are indicated on the polyhedron scan shown below and a color palette is introduced, which will be used later in the construction of the sylahedron.

Net_of_szilassi_polyhedron.png

Let's add variables to the workspace Engee that characterize the Cartesian coordinates of the vertices of the Sylahedron. These coordinates are determined from the conditions that the geometric center of the polyhedron is located at the origin of the coordinates, and the length of its smallest face is one.

In [ ]:
# Координаты вершин: 
#           координаты [x, y, z]    № вершины
Вершины = [
            [12,  0, 12],           # 0
            [-12, 0, 12],           # 1
            [0, 12.6, -12],         # 2
            [0, -12.6, -12],        # 3
            [2, -5, -8],            # 4
            [-2, 5, -8],            # 5
            [3.75, 3.75, -3],       # 6
            [-3.75, -3.75, -3],     # 7
            [4.5, -2.5, 2],         # 8
            [-4.5, 2.5, 2],         # 9
            [7, 0, 2],              # 10
            [-7, 0, 2],             # 11
            [7, 2.5, 2],            # 12
            [-7, -2.5, 2]           # 13
          ];

# извлечение векторов координат вершин по осям
Вершины_матрица = Base.stack(Вершины, dims = 1);
Вершины_x = Вершины_матрица[:, 1];
Вершины_y = Вершины_матрица[:, 2];
Вершины_z = Вершины_матрица[:, 3];

In the vector Вершины The coordinate vectors for the vertices with the ordinal numbers indicated in the comments are given. For the convenience of their construction, the coordinates along the axes are extracted into separate vectors.

Connecting vertices

To build faces using the function Plots.mesh3d() It is necessary to define three vectors (I, J, K), the corresponding indices of which are the vertices of the triangle belonging to the face of the polyhedron. For example, in the face A1 there are 4 disjoint triangles formed by the vertices 0-10-12, 0-4-10, 4-2-10 and 4-3-2.
Thus, we divide each face of the sylahedron into disjoint triangles, and write the vertices forming them into the corresponding indices of the vectors I, J, K. To correctly display the color fill of the faces during construction, the vertices of the triangles should be inserted into the vectors without changing the direction of traversal of the vertices for one face.

In [ ]:
# разбиение граней на треугольники:
# грань А1 (состоит из треугольников 0-10-12, 0-4-10, 4-2-10, 4-3-2)
А1_i = [0,  0,  4,  4];
А1_j = [10, 4,  2,  3];
A1_k = [12, 10, 10, 2];
Соединения_А1 = (А1_i, А1_j, A1_k);

# грань А2
А2_i = [1,  1,  5,  5];
А2_j = [11, 5,  3,  2];
A2_k = [13, 11, 11, 3];
Соединения_А2 = (А2_i, А2_j, A2_k);

# грань Б1
Б1_i = [0, 0,  0,  4];
Б1_j = [8, 1,  13, 8];
Б1_k = [4, 13, 8,  7];
Соединения_Б1 = (Б1_i, Б1_j, Б1_k);

# грань Б2
Б2_i = [1, 1,  1,  5];
Б2_j = [9, 0,  12, 9];
Б2_k = [5, 12, 9,  6];
Соединения_Б2 = (Б2_i, Б2_j, Б2_k);

# грань В1
В1_i = [10, 10, 10, 5];
В1_j = [8,  7,  6,  2];
В1_k = [7,  6,  2,  6];
Соединения_В1 = (В1_i, В1_j, В1_k);

# грань В2
В2_i = [11, 11, 11, 7];
В2_j = [9,  6,  7,  4];
В2_k = [6,  7,  3,  3];
Соединения_В2 = (В2_i, В2_j, В2_k);

# грань Г
Г_i = [11, 10, 8,  8];
Г_j = [8,  9,  11, 9];
Г_k = [13, 12, 9,  10];
Соединения_Г = (Г_i, Г_j, Г_k);

# вектора значений для построения граней
Соединения = [Соединения_А1, Соединения_А2, Соединения_Б1, 
              Соединения_Б2, Соединения_В1, Соединения_В2, Соединения_Г];
Радуга =  [:red, :orange, :yellow, :green, :cyan, :blue, :purple];
Подпись = ["A1", "A2",    "Б1",    "Б2",   "В1",  "В2",  "Г"    ];

The resulting vectors are combined into tuples for transmission to the function mesh3d(), the variables of the color palette and the designations of the faces of the polyhedron are defined.

Construction of a sylahedron

Connecting the library Plots.jl and a backend for building:

In [ ]:
# подключение библиотеки и бэкенда
using Plots;
plotlyjs();

Let's introduce the function Грань() to plot vertices and faces by index:

In [ ]:
# функция для построения вершин и граней
function Грань(номер)
    if номер == 0 
        Plots.scatter3d(Вершины_x, Вершины_y, Вершины_z;
                        label="вершины", color = :black, markersize = 1,
                        xlabel = "x", ylabel = "y", zlabel = "z",
                        camera = (130, 20))
    else
        Plots.mesh3d!(Вершины_x, Вершины_y, Вершины_z;
                      connections = Соединения[номер],
                      color = Радуга[номер], label = Подпись[номер])
    end
end;

Let's construct the vertices and the resulting faces in a cycle:

In [ ]:
# построение вершин
Plots.scatter3d(Вершины_x, Вершины_y, Вершины_z;
                label="вершины", color = :black, markersize = 1)

# построение граней в цикле
for N in 1:7
    Грань(N)
end

# оформление сцены
plot!(xlabel = "x", ylabel = "y", zlabel = "z", camera = (130, 20))
Out[0]:

The connected backend ensures the construction of a polyhedron with high interactivity. The silahedron can be scaled, rotated, and the display of elements (faces and vertices) can be enabled or disabled.

In conclusion, let's create an animation of the sequential construction of the faces of the sylahedron.:

In [ ]:
# анимация последовательного построения граней
анимация = @animate for N in [0, 7, 6, 5, 2, 1, 3, 4]
    Грань(N)
end;

gif(анимация, "Силаэдр.gif", fps = 1)
[ Info: Saved animation to /user/start/examples/math_and_optimization/silaedr/Силаэдр.gif
Out[0]:
No description has been provided for this image

Conclusion

In this example, we examined the construction of the Silashi polyhedron by coordinates using the function mesh3d() from the library Plots.jl.