我有一个OBJ文件,由Meshlab生成的顶点和脸数据。在MATLAB中,我在另一个数组(5937x3)和面(11870x3)数据中使用了带有顶点数据的“补丁”函数,结果如下:
Simplified version of the code
[V,F] = read_vertices_and_faces_from_obj_file(filename);
patch('Vertices',V,'Faces',F,'FaceColor','r','LineStyle','-')
axis equal结果
问题是,我如何在Python中做到这一点?有一种类似于Matlab的简单方法??
我真的很感激你的帮助。
发布于 2016-05-26 21:02:29
最好的选择是利用来自matplotlib库的matplotlib。
这里也问了一个类似的问题。也许从这个问题中略作编辑的代码摘录将对您有所帮助。
代码:
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import matplotlib.pyplot as plt
fig = plt.figure()
ax = Axes3D(fig)
# Specify 4 vertices
x = [0,1,1,0] # Specify x-coordinates of vertices
y = [0,0,1,1] # Specify y-coordinates of vertices
z = [0,1,0,1] # Specify z-coordinates of vertices
verts = [zip(x, y, z)] # [(0,0,0), (1,0,1), (1,1,0), (0,1,1)]
tri = Poly3DCollection(verts) # Create polygons by connecting all of the vertices you have specified
tri.set_color(colors.rgb2hex(sp.rand(3))) # Give the faces random colors
tri.set_edgecolor('k') # Color the edges of every polygon black
ax.add_collection3d(tri) # Connect polygon collection to the 3D axis
plt.show()https://stackoverflow.com/questions/37470076
复制相似问题