random.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:iutils 作者: inconvergent 项目源码 文件源码
def darts(n, xx, yy, rr, dst):
  """
  get at most n random, uniformly distributed, points in a circle.
  centered at (xx,yy), with radius rr. points are no closer to each other
  than dst.
  """

  ## remove new nodes that are too close to other
  ## new nodes

  visited = set()
  dartsxy = random_points_in_circle(n, xx, yy, rr)
  tree = kdt(dartsxy)
  near = tree.query_ball_point(dartsxy, dst)
  jj = []
  for j,n in enumerate(near):

    if len(visited.intersection(n))<1:
      jj.append(j)
      visited.add(j)

  res = dartsxy[jj,:]
  return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号