def _intersect_circle(self, center, radius, x):
""" upper intersection of line parallel to y axis and a circle
where line is given by x origin
circle by center, radius as float
return float y of upper intersection point, float angle
"""
dx = x - center.x
d = (radius * radius) - (dx * dx)
if d <= 0:
if x > center.x:
return center.y, 0
else:
return center.y, pi
else:
y = sqrt(d)
return center.y + y, atan2(y, dx)
评论列表
文章目录