本演示介绍如何使用Plots.jl
库中的函数mesh3d()
构建西拉多面体(Silahedron)。
Силаэдр- 是一个非凸环形多面体,欧拉-平卡列特性中的以下等式成立
$$h = \frac{(f-4)(f-3)}{12},$$
其中$f = 7$ 是多面体的面数,$h=1$ 是嵌入多面体的曲面的孔数。
这个等式源于这样一个条件,即在这样的多面体中,每个面都与其他面有一条公共边。
一个正六面体有 7 个六面体面、14 个顶点和 21 条边。在本例中,我们将利用现有的顶点坐标在直角坐标系中构建这个多面体。
首先,让我们介绍一下面和顶点的符号。顶点有 0 至 13 的连续数字符号,成对的面有连续的字母数字符号:A1、A2、B1、B2、B1、B2、B1、B2,未配对的边用字母G表示。
下面的多面体扫面图显示了相应的名称和色调,这些名称和色调将进一步用于构造正 silahedron。
让我们在Engee工作空间中添加描述正四面体顶点笛卡尔坐标的变量。这些坐标是根据多面体的几何中心位于原点和最小面的长度等于 1 的条件确定的。
在向量Вершины
中,给出了注释中指定序号的顶点坐标向量。为便于构建,沿坐标轴的坐标被提取为单独的矢量。
要使用Plots.mesh3d()
函数构造面,必须定义三个向量(I、J、K),其对应的索引是属于多面体面的三角形顶点。例如,在面 A1 中有 4 个不相交的三角形,分别由顶点 0-10-12、0-4-10、4-2-10 和 4-3-2构成。
因此,让我们将正方体的每个面划分为不相交的三角形,并将形成这些三角形的顶点写入向量 I、J、K 的相应索引中。为了在构建过程中正确显示面的颜色填充,应在不改变一个面的顶点遍历方向的情况下将三角形的顶点输入向量。
将获得的向量组合成图元传递给函数mesh3d()
,并定义调色板变量和多面体面的名称。
让我们来介绍函数Грань()
,它可以按索引构建顶点和面:
连接后端可构建具有高度交互性的多面体。正方体可以缩放、旋转,元素(面和顶点)的显示可以打开或关闭。
[ Info: Saved animation to /user/start/examples/math_and_optimization/silaedr/Силаэдр.gif
在本例中,我们使用Plots.jl
库中的函数mesh3d()
根据坐标构建了西拉多面体。
{"id": "4f678dc1-d1f8-48b4-a58b-94117ffb7bc3", "data": [{"showlegend": true, "mode": "markers", "xaxis": "x", "colorbar": {"y": 0.5329861111111112, "title": {"text": ""}, "len": 0.914342738407699, "x": 0.9934383202099737}, "name": "вершины", "yaxis": "y", "zaxis": "z", "legendgroup": "вершины", "z": [12, 12, -12, -12, -8, -8, -3, -3, 2, 2, 2, 2, 2, 2], "marker": {"symbol": "circle", "color": "rgba(0, 0, 0, 1)", "line": {"color": "rgba(0, 0, 0, 1)", "width": 1}, "size": 2}, "y": [0, 0, 12.6, -12.6, -5, 5, 3.75, -3.75, -2.5, 2.5, 0, 0, 2.5, -2.5], "type": "scatter3d", "scene": "scene", "x": [12, -12, 0, 0, 2, -2, 3.75, -3.75, 4.5, -4.5, 7, -7, 7, -7], "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 14, "currentCount": 14}}}, {"showlegend": true, "xaxis": "x", "colorbar": {"y": 0.5329861111111112, "title": {"text": ""}, "len": 0.914342738407699, "x": 0.9934383202099737}, "j": [10, 4, 2, 3], "k": [12, 10, 10, 2], "name": "A1", "opacity": null, "colorscale": [[0, "rgba(255, 0, 0, 1.000)"], [1, "rgba(255, 0, 0, 1.000)"]], "yaxis": "y", "zaxis": "z", "z": [12, 12, -12, -12, -8, -8, -3, -3, 2, 2, 2, 2, 2, 2], "color": "rgba(255, 0, 0, 1.000)", "y": [0, 0, 12.6, -12.6, -5, 5, 3.75, -3.75, -2.5, 2.5, 0, 0, 2.5, -2.5], "type": "mesh3d", "scene": "scene", "showscale": false, "i": [0, 0, 4, 4], "x": [12, -12, 0, 0, 2, -2, 3.75, -3.75, 4.5, -4.5, 7, -7, 7, -7], "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 14, "currentCount": 14}}}, {"showlegend": true, "xaxis": "x", "colorbar": {"y": 0.5329861111111112, "title": {"text": ""}, "len": 0.914342738407699, "x": 0.9934383202099737}, "j": [11, 5, 3, 2], "k": [13, 11, 11, 3], "name": "A2", "opacity": null, "colorscale": [[0, "rgba(255, 165, 0, 1.000)"], [1, "rgba(255, 165, 0, 1.000)"]], "yaxis": "y", "zaxis": "z", "z": [12, 12, -12, -12, -8, -8, -3, -3, 2, 2, 2, 2, 2, 2], "color": "rgba(255, 165, 0, 1.000)", "y": [0, 0, 12.6, -12.6, -5, 5, 3.75, -3.75, -2.5, 2.5, 0, 0, 2.5, -2.5], "type": "mesh3d", "scene": "scene", "showscale": false, "i": [1, 1, 5, 5], "x": [12, -12, 0, 0, 2, -2, 3.75, -3.75, 4.5, -4.5, 7, -7, 7, -7], "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 14, "currentCount": 14}}}, {"showlegend": true, "xaxis": "x", "colorbar": {"y": 0.5329861111111112, "title": {"text": ""}, "len": 0.914342738407699, "x": 0.9934383202099737}, "j": [8, 1, 13, 8], "k": [4, 13, 8, 7], "name": "Б1", "opacity": null, "colorscale": [[0, "rgba(255, 255, 0, 1.000)"], [1, "rgba(255, 255, 0, 1.000)"]], "yaxis": "y", "zaxis": "z", "z": [12, 12, -12, -12, -8, -8, -3, -3, 2, 2, 2, 2, 2, 2], "color": "rgba(255, 255, 0, 1.000)", "y": [0, 0, 12.6, -12.6, -5, 5, 3.75, -3.75, -2.5, 2.5, 0, 0, 2.5, -2.5], "type": "mesh3d", "scene": "scene", "showscale": false, "i": [0, 0, 0, 4], "x": [12, -12, 0, 0, 2, -2, 3.75, -3.75, 4.5, -4.5, 7, -7, 7, -7], "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 14, "currentCount": 14}}}, {"showlegend": true, "xaxis": "x", "colorbar": {"y": 0.5329861111111112, "title": {"text": ""}, "len": 0.914342738407699, "x": 0.9934383202099737}, "j": [9, 0, 12, 9], "k": [5, 12, 9, 6], "name": "Б2", "opacity": null, "colorscale": [[0, "rgba(0, 128, 0, 1.000)"], [1, "rgba(0, 128, 0, 1.000)"]], "yaxis": "y", "zaxis": "z", "z": [12, 12, -12, -12, -8, -8, -3, -3, 2, 2, 2, 2, 2, 2], "color": "rgba(0, 128, 0, 1.000)", "y": [0, 0, 12.6, -12.6, -5, 5, 3.75, -3.75, -2.5, 2.5, 0, 0, 2.5, -2.5], "type": "mesh3d", "scene": "scene", "showscale": false, "i": [1, 1, 1, 5], "x": [12, -12, 0, 0, 2, -2, 3.75, -3.75, 4.5, -4.5, 7, -7, 7, -7], "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 14, "currentCount": 14}}}, {"showlegend": true, "xaxis": "x", "colorbar": {"y": 0.5329861111111112, "title": {"text": ""}, "len": 0.914342738407699, "x": 0.9934383202099737}, "j": [8, 7, 6, 2], "k": [7, 6, 2, 6], "name": "В1", "opacity": null, "colorscale": [[0, "rgba(0, 255, 255, 1.000)"], [1, "rgba(0, 255, 255, 1.000)"]], "yaxis": "y", "zaxis": "z", "z": [12, 12, -12, -12, -8, -8, -3, -3, 2, 2, 2, 2, 2, 2], "color": "rgba(0, 255, 255, 1.000)", "y": [0, 0, 12.6, -12.6, -5, 5, 3.75, -3.75, -2.5, 2.5, 0, 0, 2.5, -2.5], "type": "mesh3d", "scene": "scene", "showscale": false, "i": [10, 10, 10, 5], "x": [12, -12, 0, 0, 2, -2, 3.75, -3.75, 4.5, -4.5, 7, -7, 7, -7], "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 14, "currentCount": 14}}}, {"showlegend": true, "xaxis": "x", "colorbar": {"y": 0.5329861111111112, "title": {"text": ""}, "len": 0.914342738407699, "x": 0.9934383202099737}, "j": [9, 6, 7, 4], "k": [6, 7, 3, 3], "name": "В2", "opacity": null, "colorscale": [[0, "rgba(0, 0, 255, 1.000)"], [1, "rgba(0, 0, 255, 1.000)"]], "yaxis": "y", "zaxis": "z", "z": [12, 12, -12, -12, -8, -8, -3, -3, 2, 2, 2, 2, 2, 2], "color": "rgba(0, 0, 255, 1.000)", "y": [0, 0, 12.6, -12.6, -5, 5, 3.75, -3.75, -2.5, 2.5, 0, 0, 2.5, -2.5], "type": "mesh3d", "scene": "scene", "showscale": false, "i": [11, 11, 11, 7], "x": [12, -12, 0, 0, 2, -2, 3.75, -3.75, 4.5, -4.5, 7, -7, 7, -7], "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 14, "currentCount": 14}}}, {"showlegend": true, "xaxis": "x", "colorbar": {"y": 0.5329861111111112, "title": {"text": ""}, "len": 0.914342738407699, "x": 0.9934383202099737}, "j": [8, 9, 11, 9], "k": [13, 12, 9, 10], "name": "Г", "opacity": null, "colorscale": [[0, "rgba(128, 0, 128, 1.000)"], [1, "rgba(128, 0, 128, 1.000)"]], "yaxis": "y", "zaxis": "z", "z": [12, 12, -12, -12, -8, -8, -3, -3, 2, 2, 2, 2, 2, 2], "color": "rgba(128, 0, 128, 1.000)", "y": [0, 0, 12.6, -12.6, -5, 5, 3.75, -3.75, -2.5, 2.5, 0, 0, 2.5, -2.5], "type": "mesh3d", "scene": "scene", "showscale": false, "i": [11, 10, 8, 8], "x": [12, -12, 0, 0, 2, -2, 3.75, -3.75, 4.5, -4.5, 7, -7, 7, -7], "metadata": {"shouldEnableSmartZoom": false, "smartZoomParams": {"minCount": 25000, "maxCount": 14, "currentCount": 14}}}], "config": {"showlegend": true, "paper_bgcolor": "rgba(255, 255, 255, 1.000)", "annotations": [], "height": 400, "margin": {"l": 0, "b": 20, "r": 0, "t": 20}, "plot_bgcolor": "rgba(255, 255, 255, 1.000)", "scene": {"camera": {"eye": {"y": 1.57045921124314, "z": 0.8892523726467387, "x": 1.871600407021681}, "projection": "orthographic"}, "xaxis": {"tickangle": 0, "showline": true, "gridcolor": "rgba(0, 0, 0, 0.1)", "showticklabels": true, "gridwidth": 0.5, "visible": true, "ticks": "inside", "range": [-12.72, 12.72], "tickmode": "array", "tickvals": [-10, -5, 0, 5, 10], "tickcolor": "rgb(0, 0, 0)", "ticktext": ["-10", "-5", "0", "5", "10"], "linecolor": "rgba(0, 0, 0, 1)", "showgrid": true, "zeroline": false, "type": "linear", "tickfont": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 11}, "title": {"text": "x", "font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 15}}, "zerolinecolor": "rgba(0, 0, 0, 1)", "mirror": false}, "domain": {"y": [0.07581474190726165, 0.9901574803149606], "x": [0.07646908719743364, 0.9934383202099737]}, "yaxis": {"tickangle": 0, "showline": true, "gridcolor": "rgba(0, 0, 0, 0.1)", "showticklabels": true, "gridwidth": 0.5, "visible": true, "ticks": "inside", "range": [-13.356, 13.356], "tickmode": "array", "tickvals": [-10, -5, 0, 5, 10], "tickcolor": "rgb(0, 0, 0)", "ticktext": ["-10", "-5", "0", "5", "10"], "linecolor": "rgba(0, 0, 0, 1)", "showgrid": true, "zeroline": false, "type": "linear", "tickfont": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 11}, "title": {"text": "y", "font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 15}}, "zerolinecolor": "rgba(0, 0, 0, 1)", "mirror": false}, "zaxis": {"tickangle": 0, "showline": true, "gridcolor": "rgba(0, 0, 0, 0.1)", "showticklabels": true, "gridwidth": 0.5, "visible": true, "ticks": "inside", "range": [-12.72, 12.72], "tickmode": "array", "tickvals": [-10, -5, 0, 5, 10], "tickcolor": "rgb(0, 0, 0)", "ticktext": ["-10", "-5", "0", "5", "10"], "linecolor": "rgba(0, 0, 0, 1)", "showgrid": true, "zeroline": false, "type": "linear", "tickfont": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 11}, "title": {"text": "z", "font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 15}}, "zerolinecolor": "rgba(0, 0, 0, 1)", "mirror": false}, "aspectratio": {"x": 0.9838681468061972, "y": 1.033061554146507, "z": 0.9838681468061972}, "aspectmode": "auto"}, "legend": {"yanchor": "auto", "xanchor": "auto", "bordercolor": "rgba(0, 0, 0, 1)", "bgcolor": "rgba(255, 255, 255, 1.000)", "borderwidth": 1, "tracegroupgap": 0, "y": 1, "font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 11}, "title": {"font": {"color": "rgba(0, 0, 0, 1)", "family": "sans-serif", "size": 15}, "text": ""}, "traceorder": "normal", "x": 1}, "width": 1034}}