Ejemplo n.º 1
0
    def collide(self, wall: Wall, dt):
        points = wall.get_dots()
        glob_moment = 0
        glob_force = Vector(0, 0)

        for point in points:
            if abs(point - self.get_cords()) > self.r:
                continue

            for dot in self.dots:

                dot_coords = dot.get_cords()
                dot_force = Vector(0, 0)
                l_2 = (point.x - dot_coords.x)**2 + (
                    point.y -
                    dot_coords.y)**2 + 0.01  #because of division by zero

                if l_2 < dot.get_r()**2:
                    dot_force += FORCE_CONSTANT * (dot.get_r() - math.sqrt(
                        l_2)) / abs(dot_coords - point) * (dot_coords - point)

                dot_moment = (dot_coords - self.get_cords()).cross(dot_force)

                glob_force += dot_force
                glob_moment += dot_moment

        beta = glob_moment / self.get_I()
        a = glob_force / self.m
        self.v += a * dt
        self.w += beta * dt
Ejemplo n.º 2
0
 def collide(self, wall: Wall):
     points = wall.get_dots()
     for point in points:
         if abs(point - self.get_cords()) < self.r:
             return True
     return False