Ejemplo n.º 1
0
 def doesCircleCollideWithBox(self, box):
     dstBetweenCenters = function.getDistanceBetweenPoints(self.center, box.center)
     if dstBetweenCenters > self.radius + box.distanceCtrToPt:
         return False
     
     for point in box.points:
         if function.getDistanceBetweenPoints(self.center, point) <= self.radius:
             return True
     
     #HIER ZIT DE FOUT
     for i in range (0, 4):
         if type(box.sides[i].gradient) == str:
             orthogonal = Line(self.center, 0.0)
         elif box.sides[i].gradient != 0:
             orthogonal = Line(self.center, - 1.0 / box.sides[i].gradient)
         elif box.sides[i].gradient == 0:
             orthogonal = Line(self.center, 'vertical')
         
         nearestPoint = orthogonal.getIntersectionWithLineSegment(box.sides[i])
         if nearestPoint != False:
             if nearestPoint == 'coinciding':
                 return True
             else:
                 dstCenterToSide = function.getDistanceBetweenPoints(self.center, nearestPoint)
                 if dstCenterToSide <= self.radius:
                     return True
     return False
Ejemplo n.º 2
0
 def doCirclesCollide(self, otherCircle):
     if function.getDistanceBetweenPoints(self.center, otherCircle.center) <= self.radius + otherCircle.radius:
         return True
     return False