def circlepoint(c,r):
"""Generate a point [x,y] lying on a circle by the circle equation.
Args:
c (list): The position of circle centre.
r (float): The radius of the circle.
Returns:
A point lies on a circle. The point position is random.
"""
x = random.uniform(-r,r) # Randomly find the x position.
negative = bool(random.getrandbits(1)) # Randomly set whether the point is on the positive y side or negative side.
y = math.sqrt(r**2-x**2) # The equation of the circle.
if negative:
y = -y
return [x+c[0],y+c[1]]
dataset.py 文件源码
python
阅读 29
收藏 0
点赞 0
评论 0
评论列表
文章目录