intersection.py 文件源码

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

项目:planetplanet 作者: rodluger 项目源码 文件源码
def GetRootsPolynomial(a, b, xE, yE, xC, yC, r):
    '''

    '''

    # Define some stuff
    r2 = r * r;
    a2 = a * a;
    b2 = b * b;
    a2b2 = a2 / b2;
    x0 = xE - xC;
    y0 = yE - yC;
    y2 = y0 * y0;
    x2 = x0 * x0;

    # Get the coefficients
    A = a2b2 - 1.;
    B = -2. * x0 * a2b2;
    C = r2 - y2 - a2 + a2b2 * x2;
    D = 4. * y2 * a2b2;
    c4 = A * A;
    c3 = 2. * A * B;
    c2 = 2. * A * C + B * B + D;
    c1 = 2. * B * C - 2. * D * x0;
    c0 = C * C - (b2 - x2) * D;

    # Get the real roots
    roots = [r.real + xC for r in np.roots([c4, c3, c2, c1, c0]) 
             if np.abs(r.imag) < tol]
    return roots
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号