def tang(self, r2, r3, r4):
"""Quality function that takes 3 radiuses and makes 4 circles that are kissing"""
c2 = Circle(0, 0, r2) # The first circle is placed at the origin
c3 = Circle(r2 + r3, 0, r3) # The second circle is placed kissing the first circle to the right
x = (r2 * r2 + r2 * r4 + r2 * r3 - r3 * r4) / (
r2 + r3) # Magic triangle maths to figure out where the of the third circle should go
y = cmath.sqrt((r2 + r4) * (r2 + r4) - x * x)
c4 = Circle(x.real, y.real, r4)
c1 = self.outer(c2, c3, c4) # The outer circle is generated based on the first 3
offx = 0 - c1.x
offy = 0 - c1.y
c2.correct(offx, offy) # Offsets all the circles so the biggest circle is centered instead of the first circle
c3.correct(offx, offy)
c4.correct(offx, offy)
c1.correct(offx, offy)
return c1, c2, c3, c4
评论列表
文章目录