我想绘制由 3D 向量在笛卡尔坐标 x、y、z 中给出的数据的表面。数据不能用平滑函数表示。
因此,首先我们使用函数生成一些虚拟数据,该函数eq_points(N_count, r)返回一个数组points,其中包含对象表面上每个点的 x、y、z 坐标。数量omega是立体角,现在不感兴趣。
#credit to Markus Deserno from MPI
#https://www.cmu.edu/biolphys/deserno/pdf/sphere_equi.pdf
def eq_points(N_count, r):
points = []
a = 4*np.pi*r**2/N_count
d = np.sqrt(a)
M_theta = int(np.pi/d)
d_theta = np.pi/M_theta
d_phi = a/d_theta
for m in range(M_theta):
theta = np.pi*(m+0.5)/M_theta
M_phi = int(2*np.pi*np.sin(theta)/d_phi)
for n in range(M_phi):
phi = 2*np.pi*n/M_phi
points.append(np.array([r*np.sin(theta)*np.cos(phi),
r*np.sin(theta)*np.sin(phi),
r*np.cos(theta)]))
omega = 4*np.pi/N_count
return np.array(points), omega
#starting plotting sequence
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
points, …Run Code Online (Sandbox Code Playgroud)