def _samp_sphere(self, radius = 1):
# from http://stackoverflow.com/a/5408843/2565317
if radius is not np.array:
radius = np.array(radius)
n = radius.size
phi = np.random.rand(n) * 2 * np.pi
costheta = np.random.rand(n) * 2 - 1
u = np.random.rand(n)
theta = np.arccos( costheta )
r = radius * u ** (1. / 3)
x = r * np.sin(theta) * np.cos(phi)
y = r * np.sin(theta) * np.sin(phi)
z = r * np.cos(theta)
return x, y, z
#%%
评论列表
文章目录