使用trimesh计算ply模型的法线及显示
import trimesh
import matplotlib.pyplot as plt
# 读取点云文件
mesh = trimesh.load_mesh('test.ply')
# 计算法线
mesh.vertex_normals
# 创建一个新的图形窗口
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# 绘制顶点和法线
ax.scatter(mesh.vertices[:, 0], mesh.vertices[:, 1], mesh.vertices[:, 2])
ax.quiver(mesh.vertices[:, 0], mesh.vertices[:, 1], mesh.vertices[:, 2],
mesh.vertex_normals[:, 0], mesh.vertex_normals[:, 1], mesh.vertex_normals[:, 2],
length=1.1, color='r')
# 显示图形
plt.show()
效果如下:


浙公网安备 33010602011771号