0


python在球面上随机生成均匀点最简单的方法

如果在球坐标系的\theta(与Z轴夹角)和\phi(与X轴夹角)下均匀分布产生点,点会集中在球的两极,所以应该将\theta映射到arccos(\theta)上来产生均匀分布的点:

  1. import numpy as np
  2. import random
  3. def generate_point():
  4. phi = random.uniform(0, 2*pi)
  5. theta = np.arccos(random.uniform(-1, 1))
  6. return(theta, phi)

数学过程参见Sphere Point Picking -- from Wolfram MathWorld


本文转载自: https://blog.csdn.net/skyxak/article/details/122109488
版权归原作者 kui_an 所有, 如有侵权,请联系我们删除。

“python在球面上随机生成均匀点最简单的方法”的评论:

还没有评论