【发布时间】:2018-11-01 02:53:29
【问题描述】:
原创(2018.11.01)
我有 3 个 numpy:x、y、z,由我的激光扫描仪创建(40 度 / 1 步)。 我想用它们来构建一个 3D 模型。
我觉得应该是matplotlib.tri
但我不知道确定三角数据
这是我的数据:https://www.dropbox.com/s/d9p62kv9jcq9bwh/xyz.zip?dl=0
原型号:https://i.imgur.com/XSyONff.jpg
代码:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.tri as mtri
x_all=np.load("x.npy")
y_all=np.load("y.npy")
z_all=np.load("z.npy")
tri = #I have no idea...
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot_trisurf(x_all,y_all,z_all,triangles=tri.triangles)
非常感谢。
更新(2018.11.02)
我尝试这种方式来确定三角数据 Delaunay Triangulation of points from 2D surface in 3D with python?
代码:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.tri as mtri
from stl import mesh
x_all=np.load("x.npy")
y_all=np.load("y.npy")
z_all=np.load("z.npy")
model=np.vstack((x_all,y_all,z_all))
model=np.transpose(model)
model -= model.mean(axis=0)
rad = np.linalg.norm(model, axis=1)
zen = np.arccos(model[:,-1] / rad)
azi = np.arctan2(model[:,1], model[:,0])
tris = mtri.Triangulation(zen, azi)
plt.show()
我的模型看起来像:
https://i.stack.imgur.com/KVPHP.png
https://i.stack.imgur.com/LLQsQ.png
https://i.stack.imgur.com/HdzFm.png
虽然它有更好的表面,但我的模型上有一个大洞。有修复它的想法吗?
【问题讨论】:
标签: python python-3.x