1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib.tri import Triangulation
def generate_uniform_points_on_sphere(num_points): points = [] phi = np.arccos(1 - 2 * np.linspace(0, 1, num_points)) theta = np.pi * (3. - np.sqrt(5.)) * np.arange(num_points) x, y, z = np.cos(theta) * np.sin(phi), np.sin(theta) * np.sin(phi), np.cos(phi) points = np.column_stack((x, y, z))
return points
def select_uniform_points(base_points, num_selected_points): num_base_points = len(base_points)
selected_indices = np.linspace(0, num_base_points - 1, num_selected_points, dtype=int) selected_points = base_points[selected_indices]
return selected_points
num_points = 120 base_points = generate_uniform_points_on_sphere(num_points)
num_selected_points = 60 selected_points = select_uniform_points(base_points, num_selected_points)
jg=open("xyz.txt",'w')
print("All points:") for i, point in enumerate(base_points): jg.writelines(str(point[0]) + ' ' + str(point[1]) + ' ' + str(point[2]) + '\n')
"""for i, point in enumerate(selected_points): #生成O #print(f"Point {i + 1}: {point}") jg.writelines(str(point[0]) + ' ' + str(point[1]) + ' ' + str(point[2]) + '\n') for i, point in enumerate(selected_points): #生成H jg.writelines(str(point[0]) + ' ' + str(point[1]) + ' ' + str(point[2]) + '\n')"""
|