clustering.py
def approximate(p1, r1, p2, r2):
    """Approximate a circle intersection point."""
    d = np.linalg.norm(p1-p2)
    if abs(d)<exp(1e-5): 
        return None
    dr1, dr2 = r1 / d, r2 / d
    p = p2-p1
    dp1, dp2 = dr1*p, dr2*p
    p11, p12, p21, p22 = p1 + dp1, p1-dp1, p2 + dp2, p2-dp2 # Find nearest pair of intersection point belonging to different # circles.
    n1, n2 = p11, p21
    d1, dt = np.linalg.norm(p11-p21), np.linalg.norm(p11-p22)
    if dt < d1: d1, n2 = dt, p22
    dt = np.linalg.norm(p12-p21)
    if dt < d1: d1, n1, n2 = dt, p12, p21
    dt = np.linalg.norm(p12-p22)
    if dt < d1: n1, n2 = p12, p22
    # return middle of line between two nearest points as result 
    return n1 / 2 + n2 / 2
Approximate a circle intersection point.
Approximate a circle intersection point.
Approximate a circle intersection point .
def approximate(p1, r1, p2, r2):
    d = np.linalg.norm(p1-p2)
    if abs(d)<exp(1e-5): 
        return None
    dr1, dr2 = r1 / d, r2 / d
    p = p2-p1
    dp1, dp2 = dr1*p, dr2*p
    p11, p12, p21, p22 = p1 + dp1, p1-dp1, p2 + dp2, p2-dp2 
    n1, n2 = p11, p21
    d1, dt = np.linalg.norm(p11-p21), np.linalg.norm(p11-p22)
    if dt < d1: d1, n2 = dt, p22
    dt = np.linalg.norm(p12-p21)
    if dt < d1: d1, n1, n2 = dt, p12, p21
    dt = np.linalg.norm(p12-p22)
    if dt < d1: n1, n2 = p12, p22
    return n1 / 2 + n2 / 2
def approximate ( p1 , r1 , p2 , r2 ) : d = np . linalg . norm ( p1 - p2 ) if abs ( d ) < exp ( 1e-5 ) : return None dr1 , dr2 = r1 / d , r2 / d p = p2 - p1 dp1 , dp2 = dr1 * p , dr2 * p p11 , p12 , p21 , p22 = p1 + dp1 , p1 - dp1 , p2 + dp2 , p2 - dp2 n1 , n2 = p11 , p21 d1 , dt = np . linalg . norm ( p11 - p21 ) , np . linalg . norm ( p11 - p22 ) if dt < d1 : d1 , n2 = dt , p22 dt = np . linalg . norm ( p12 - p21 ) if dt < d1 : d1 , n1 , n2 = dt , p12 , p21 dt = np . linalg . norm ( p12 - p22 ) if dt < d1 : n1 , n2 = p12 , p22 return n1 / 2 + n2 / 2
Approximate a circle intersection point.
Approximate a circle intersection point .
"""Approximate a circle intersection point.""" # Find nearest pair of intersection point belonging to different # circles. # return middle of line between two nearest points as result 
p1
r1
p2
r2