使用Plotly从点云生成曲面网格

2024-05-08 00:46:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试从点云scatter plot生成曲面。我环顾四周,解决方案似乎是从云点生成三角形,然后生成最终网格。然而,我试图按照提议的程序here但是我失败了,得到了这个:trisurf attempt

遗憾的是,我的数学背景不太好,当我开始从其他awnsers和Plotly文档中阅读Jonathan Shewchuk和tessellation时,我并没有真正理解

我使用的代码如下:

#Assume X_Vir, Y_Vir and Z_Vir are list of points used to create the scatter plot

points2D = np.vstack([X_Vir, Y_Vir]).T
tri = Delaunay(points2D)    
simplices = tri.simplices
fig = ff.create_trisurf(x=X_Vir, y=Y_Vir, z=Z_Vir, simplices=simplices)
fig.show()

有人有主意吗

多谢各位


Tags: 程序网格herecreatefig数学解决方案tri
1条回答
网友
1楼 · 发布于 2024-05-08 00:46:26

我通过使用plotly的Mesh3d函数提供点坐标以及相关顶点,解决了我的问题:

fig = pot.Figure(data=[pot.Mesh3d(x=points_coord90[:,1], y=points_coord90[:,0], z=points_coord90[:,2], 
                        i=points_vert[:,0], j=points_vert[:,1], k=points_vert[:,2], 
                        intensity=bi_volt, cmin=0, cmax=2, reversescale=False, colorscale='RdYlBu', opacity=1)])

fig.show()

mesh1 如果没有顶点,另一种可能是使用plotly的alphahull选项(而不是Delaunay),但它没有满足我的需要:

fig = pot.Figure(data=[pot.Mesh3d(x=points_coord90[:,1], y=points_coord90[:,0], z=points_coord90[:,2], alphahull=0.5, opacity=0.5)])

相关问题 更多 >