i want to plot a STL file. I've allready got my Vertex's of the STL-File. The Aim is to get the faces of each triangulation which will done by
vtx=np.vstack((Vertex1[i],Vertex2[i],Vertex3[i]))
so you can see every n'th entry of Vertex1[n],Vertex2[n],Vertex3[n] belongs to the same face.
By
tri = a3d.art3d.Poly3DCollection([vtx])
we are getting a collection of 3D polygons and combine it with add_collection3d to plot all 3D polygons.
So now my Question is: Is there a way to do the Operation below without a for loop in the sense of making the code faster?
import numpy as np
import mpl_toolkits.mplot3d as a3d
import matplotlib.colors as colors
import matplotlib.pyplot as plt
Vertex1 = np.random.rand(9000,3)
Vertex2 = np.random.rand(9000,3)
Vertex3 = np.random.rand(9000,3)
ax = a3d.Axes3D(plt.figure())
for i in range(Vertex1.shape[0]):
vtx=np.vstack((Vertex1[i],Vertex2[i],Vertex3[i]))
tri = a3d.art3d.Poly3DCollection([vtx])
tri.set_color(colors.rgb2hex([0.9,0.6,0.]))
tri.set_edgecolor('k')
ax.add_collection3d(tri)
plt.show()
Thanks!