散点图的网格

时间:2019-05-09 10:19:07

标签: python matplotlib

我有一个颗粒的散点图(r theta phi / xyz)。我正在研究python(3)。我想将其划分为具有凸面的实体,这些凸面的各个面之间具有连接性。由于存在数值问题,我认为我必须使用Delaunay三角剖分来使凸体的三角形接近等边。我想根据3D散点图制作表面网格。 Delaunay有可能吗?

否则,我尝试使用Convexhull3D(请参见代码)。问题是我没有等边附近的三角形,而且我也不知道如何保存我的结果(坐标和连通性)。是否可以管理三角形表面? (只喜欢等边的东西)

# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.spatial import ConvexHull


# 8 points defining the cube corners
pts = np.load('cart.npy') # cartesian coor of the scatter plot also have 
spherical coor

hull = ConvexHull(pts)

fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")

# Plot defining corner points
ax.plot(pts.T[0], pts.T[1], pts.T[2], "ko")

# 12 = 2 * 6 faces are the simplices (2 simplices per square face)
for s in hull.simplices:
    s = np.append(s, s[0])  # Here we cycle back to the first coordinate
    ax.plot(pts[s, 0], pts[s, 1], pts[s, 2], "r-")

# Make axis label
for i in ["x", "y", "z"]:
    eval("ax.set_{:s}label('{:s}')".format(i, i))

plt.show()

结果,我需要一个网格凸面,其凸面之间具有坐标和连通性,并且单形接近等边线。

0 个答案:

没有答案
相关问题