Mayavi Mlab:绘制八面体

时间:2014-07-25 09:18:28

标签: python mayavi

我找不到绘制八面体的方法。有人会指我到一个至少绘制三角形(半透明)表面的类吗?

tvtk.tools.visual似乎只有几个基本形状。

1 个答案:

答案 0 :(得分:1)

The Gallery有一个如何使用triangular_mesh的例子:

import numpy as np
import mayavi.mlab as ML

verts = [(1,-1,0), (1,1,0), (-1,1,0), (-1,-1,0), (0,0,1), (0,0,-1)]
x, y, z = zip(*verts)
# Each triangle is a 3-tuple of indices. The indices are indices of `verts`.
triangles = [(i, (i+1)%4, j) for i in range(4) for j in (4,5)]
colorval = z
ML.triangular_mesh(x, y, z, triangles, scalars=colorval, opacity=0.75)
ML.show()

enter image description here