예제 #1
0
파일: circle.py 프로젝트: KoenP/topdown
 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
예제 #2
0
파일: circle.py 프로젝트: KoenP/topdown
 def doCirclesCollide(self, otherCircle):
     if function.getDistanceBetweenPoints(self.center, otherCircle.center) <= self.radius + otherCircle.radius:
         return True
     return False