Mayavi Mlab : Drawing octahedrons

一笑奈何 提交于 2019-12-08 03:30:39

问题


I cannot find a way to draw octahedrons. Could someone point me to a class for drawing triangular (transclucent) surfaces at the least?

tvtk.tools.visual seems to have only a few basic shapes.


回答1:


The Gallery has an example of how to use 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()



来源:https://stackoverflow.com/questions/24952215/mayavi-mlab-drawing-octahedrons

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!