def checkLines(): pa = Point(0, 0) pb = Point(1, 1) la = Line(pa, pb) print(la) print(la.reverse()) lb = Line(pb, pa) print(lb) print(lb.reverse())
def checkParallelPlacements(): # same size circles # above same x print('pl above same x') caCenter = Point(0, 0) cbCenter = Point(0, 5) ca = Circle(caCenter, 1) cb = Circle(cbCenter, 1) Tangents(ca, cb) # below same x print('pl below same x') cbCenter = Point(0, -5) cb = Circle(cbCenter, 1) Tangents(ca, cb) # left same x print('pl left same y') caCenter = Point(0, 0) cbCenter = Point(5, 0) ca = Circle(caCenter, 1) cb = Circle(cbCenter, 1) Tangents(ca, cb) # right same x print('pl right same y') caCenter = Point(0, 0) cbCenter = Point(-5, 0) ca = Circle(caCenter, 1) cb = Circle(cbCenter, 1) Tangents(ca, cb) # left no difference left & right for parallel print('pl left') caCenter = Point(0, 0) cbCenter = Point(-5, 4) ca = Circle(caCenter, 1) cb = Circle(cbCenter, 1) Tangents(ca, cb)
def checkTangentTypes(): # ca inside cb no overlay caCenter = Point(0, 0) ca = Circle(caCenter, 1) cb = Circle(caCenter, 2) print('No overlap ' + str(numTangents(ca, cb))) # ca inside cb single contract caCenter = Point(0, 0) ca = Circle(caCenter, 1) cbCenter = Point(1, 0) cb = Circle(cbCenter, 2) print('overlap Single contact internal ' + str(numTangents(ca, cb))) # ca overlap cb 2 external caCenter = Point(0, 0) ca = Circle(caCenter, 2) cbCenter = Point(1, 0) cb = Circle(cbCenter, 2) print('Ovferlap 2 touch ' + str(numTangents(ca, cb))) # ca touch cb 2 external 1 internal caCenter = Point(0, 0) ca = Circle(caCenter, 2) cbCenter = Point(4, 0) cb = Circle(cbCenter, 2) print('adjacent single touch external ' + str(numTangents(ca, cb))) # ca separate from cb ca = Circle(caCenter, 2) cbCenter = Point(5, 0) cb = Circle(cbCenter, 2) print('Separate ' + str(numTangents(ca, cb)))
def svgTangents(ca,cb): # arguments are svg shapes - Circle c0r = ca.__getitem__('r') # radius c0x = ca.__getitem__('cx') c0y = ca.__getitem__('cy') c1r = cb.__getitem__('r') # radius c1x = cb.__getitem__('cx') c1y = cb.__getitem__('cy') c0 = Circle(Point(c0x,c0y),c0r) c1 = Circle(Point(c1x,c1y),c1r) ls = Tangents(c0,c1) dwg = svgwrite.Drawing() b0 = [ls[0].begin.x,ls[0].begin.y] e0 = [ls[0].end.x,ls[0].end.y] ln0 = dwg.line(b0,e0) b1 = [ls[1].begin.x,ls[1].begin.y] e1 = [ls[1].end.x,ls[1].end.y] ln1 = dwg.line(b1,e1) return [ln0,ln1]
def checkLeftTangents(): # above left print('above left') sRadius = 1 sCenter = Point(5, 5) sCircle = Circle(sCenter, sRadius) bCenter = Point(10, 3) bCircle = Circle(bCenter, sRadius + 2) lines = Tangents(sCircle, bCircle) print('line 1 ' + printLine(lines[0]) + ' line 2 ' + printLine(lines[1])) # left same Y # print('left same y') sRadius = 1 sCenter = Point(5, 5) sCircle = Circle(sCenter, sRadius) bCenter = Point(10, 5) bCircle = Circle(bCenter, sRadius + 2) # Tangents(sCircle,bCircle) # below left # print('below left') sRadius = 1 sCenter = Point(5, 5) sCircle = Circle(sCenter, sRadius) bCenter = Point(10, 10) bCircle = Circle(bCenter, sRadius + 2)
def checkPoint(): p = Point(-1, 1) print(p)
def checkCircle(): cn = Point(3, 4) ci = Circle(cn, 121.3) print(ci)
def checkDivergentPlacements(): # ca small, cb big below same x print('dv below same x') caCenter = Point(0, 0) cbCenter = Point(0, 10) ca = Circle(caCenter, 1) cb = Circle(cbCenter, 5) Tangents(ca, cb) # ca small, cb big above same x print('dv above same x') caCenter = Point(0, 10) ca = Circle(caCenter, 1) cbCenter = Point(0, 0) cb = Circle(cbCenter, 5) Tangents(ca, cb) # ca small, cb big left same y print('dv left same y') caCenter = Point(-5, 0) ca = Circle(caCenter, 1) cbCenter = Point(0, 0) cb = Circle(cbCenter, 5) Tangents(ca, cb) # ca small, cb big right same y print('dv right same y') caCenter = Point(0, 0) ca = Circle(caCenter, 1) cbCenter = Point(-5, 0) cb = Circle(cbCenter, 5) Tangents(ca, cb) # ca small, cb big left different y print('dv left above') caCenter = Point(-5, 5) ca = Circle(caCenter, 1) cbCenter = Point(0, 0) cb = Circle(cbCenter, 5) Tangents(ca, cb) print('dv left below') caCenter = Point(-5, 1) ca = Circle(caCenter, 1) cbCenter = Point(0, 3) cb = Circle(cbCenter, 5) Tangents(ca, cb) # ca small, cb big right different y print('dv right above') caCenter = Point(0, 5) ca = Circle(caCenter, 1) cbCenter = Point(-5, 0) cb = Circle(cbCenter, 5) Tangents(ca, cb) print('dv right below') caCenter = Point(0, 0) ca = Circle(caCenter, 1) cbCenter = Point(-5, 5) cb = Circle(cbCenter, 5) Tangents(ca, cb)