如何创建以下四面体结构

时间:2019-08-25 19:31:31

标签: python python-3.x matplotlib

我正在尝试使用python3将立方盒自动切成几个四面体。像下面的图

Tetrahedron in one unit cell

Tetrahedrons in 27 unit cells

我们知道在一个单位晶胞中,我们可以找到四个顶点并生成一个四面体,如图1所示。虽然我们增加了单位晶胞的数量,但有一些需要满足的限制,每个顶点最多只能有4个边缘和所有四面体应通过顶点相互连接。如图2所示。现在,我想自动找到满足限制的顶点,其中包含更多的像元数量(如100+)。

有人可以提供任何想法吗?真的很感谢!

图2中的顶点坐标如下:

cell1 = [[-1, 1, 1, -1],    #cell structure as cell1 = [[xcoord], [ycoord], [zcoord]]
     [-1, -1, 1, 1],
     [1, -1, 1, -1]]
cell2 = [[1, 3, 1, 3], 
      [3, 3, 1, 1],
      [3, 1, 1, 3]]
cell3 = [[1, -1, 1, -1],
      [3, 5, 5, 3],
      [3, 3, 5, 5]]
cell4 = [[3, 5, 5, 3],
      [3, 5, 3, 5],
      [1, 1, -1, -1]]
cell5 = [[3, 5, 3, 5],
      [1, -1, -1, 1],
      [3, 3, 5, 5]]

绘图代码为:

def plotBox(A2, A3, A4, A5, A6):
    plt.figure()
    ax = plt.axes(projection='3d')

    verts2 = [list(zip(A2[0], A2[1], A2[2]))]
    verts3 = [list(zip(A3[0], A3[1], A3[2]))]
    verts4 = [list(zip(A4[0], A4[1], A4[2]))]
    verts5 = [list(zip(A5[0], A5[1], A5[2]))]
    verts6 = [list(zip(A6[0], A6[1], A6[2]))]

    ax.add_collection3d(Poly3DCollection(verts2, facecolors='w', linewidths=2, alpha=0.5), zs=z)
    ax.add_collection3d(Poly3DCollection(verts3, facecolors='r', linewidths=2, alpha=1), zs=x)
    ax.add_collection3d(Poly3DCollection(verts4, facecolors='w', linewidths=2, alpha=1), zs=x)
    ax.add_collection3d(Poly3DCollection(verts5, facecolors='w', linewidths=2, alpha=1), zs=x)
    ax.add_collection3d(Poly3DCollection(verts6, facecolors='w', linewidths=2, alpha=1), zs=x)
    plt.show()

A2 = [[-1, 1, 1, -1],
     [-1, -1, 1, 1],
     [1, -1, 1, -1]]
A3 = [[1, 3, 1, 3], 
      [3, 3, 1, 1],
      [3, 1, 1, 3]]
A4 = [[1, -1, 1, -1],
      [3, 5, 5, 3],
      [3, 3, 5, 5]]
A5 = [[3, 5, 5, 3],
      [3, 5, 3, 5],
      [1, 1, -1, -1]]
A6 = [[3, 5, 3, 5],
      [1, -1, -1, 1],
      [3, 3, 5, 5]]
plotBox(A2, A3, A4, A5, A6)

0 个答案:

没有答案