shape.py 文件源码

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

项目:sc8pr 作者: dmaccarthy 项目源码 文件源码
def intersectCircle(self, other):
        "Find the intersection(s) of two circles as list of points"
        R = self.radius
        r = other.radius
        d = dist(self.pos, other.pos)
        if d > r + R or d == 0 or d < abs(r - R): return []
        r2 = r * r
        x = (d*d + r2 - R*R) / (2*d)
        ux, uy = delta(self.pos, other.pos, 1)
        x0, y0 = other.pos
        x0 += x * ux
        y0 += x * uy
        if x < r:
            y = sqrt(r2 - x*x)
            return [(x0 - y * uy, y0 + y * ux), (x0 + y * uy, y0 - y * ux)]
        else: return [(x0, y0)]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号