散点网格

2024-07-07 06:28:05 发布

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

我有一个颗粒的散点图(rθφ/xyz)。我正在研究python(3)。我想让它有一个凸面的身体和两个面之间的连接。由于数值问题,我认为我必须使用Delaunay三角剖分来得到一个三角形接近等边的凸体。我想做一个三维散点图的表面网格。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()

作为结果,我需要一个网格凸体的坐标和连通性之间的面和单纯形接近等边


Tags: thefromimport网格plotasnpplt