MCPcopy Create free account
hub / github.com/ActiveState/code / cif

Function cif

recipes/Python/578029_Generalized_ApolloniGasket/recipe-578029.py:56–85  ·  view source on GitHub ↗
(a, b, c)

Source from the content-addressed store, hash-verified

54# input: 3 circles w/ each as a tuple: (complex(x,y),r)
55# output: 4 tangent circles as a tuple
56def cif(a, b, c):
57 # curvatures of the circles
58 k1 = 1.0 / a[1]
59 k2 = 1.0 / b[1]
60 k3 = 1.0 / c[1]
61 # curvatures of tangent circles
62 temp0 = 2.0 * math.sqrt(k1 * k2 + k1 * k3 + k2 * k3)
63 temp1 = k1 + k2 + k3
64 k40 = temp1 + temp0
65 k41 = temp1 - temp0
66 # centers of tangent circles
67 temp0 = 2.0 * cmath.sqrt(k1*k2*a[0]*b[0]+k1*k3*a[0]*c[0]+k2*k3*b[0]*c[0])
68 temp1 = k1 * a[0] + k2 * b[0] + k3 * c[0]
69 c40 = (temp1 + temp0) / k40
70 c41 = (temp1 - temp0) / k41
71 c42 = (temp1 - temp0) / k40
72 c43 = (temp1 + temp0) / k41
73 # radius of tangent circles
74 r0 = 1.0 / k40
75 r1 = 1.0 / k41
76 # there are 4 solutions and only 2 are correct (tangent) circles
77 # those are c0 and c1 or c2 and c3
78 c0 = (c40, r0)
79 c1 = (c41, r1)
80 c2 = (c42, r0)
81 c3 = (c43, r1)
82 if isTan4(a, b, c, c0) and isTan4(a, b, c, c1):
83 return (c0, c1)
84 else:
85 return (c2, c3)
86
87# pixel coordinate calculation
88def pxy(x, y):

Callers 1

recipe-578029.pyFile · 0.85

Calls 2

isTan4Function · 0.85
sqrtMethod · 0.45

Tested by

no test coverage detected