[問題] 程式碼請益

作者: st40182 (天羽)   2018-10-19 16:23:13
有關這段程式碼的部分:
=====================================================
import numpy as np
from stl import mesh
# Define the 8 vertices of the cube
vertices = np.array([\
[-1, -1, -1], [+1, -1, -1], [+1, +1, -1],
[-1, +1, -1], [-1, -1, +1], [+1, -1, +1],
[+1, +1, +1], [-1, +1, +1]])
# Define the 12 triangles composing the cube
faces = np.array([\
[0,3,1], [1,3,2], [0,4,7], [0,7,3],
[4,5,6], [4,6,7], [5,1,2], [5,2,6],
[2,3,6], [3,7,6], [0,1,5], [0,5,4]])
# Create the mesh
cube = mesh.Mesh(np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype))
for i, f in enumerate(faces):
for j in range(3):
cube.vectors[i][j] = vertices[f[j],:]
# Write the mesh to file "cube.stl"
cube.save('cube.stl')
===========================================
程式碼是來自這裡的其中一段
https://pypi.org/project/numpy-stl/
目的是把一群資料轉成stl檔
我想詢問的是
第三段的Create the mesh這整段是在做了些什麼
看的不是很了解
謝謝

Links booklink

Contact Us: admin [ a t ] ucptt.com