def demo_2() -> World: world = World(gravity=GRAVITY, iterations=IMPULSE_ITERATIONS) body_1 = Body([100.0, 10.0]) body_1.position = np.array([0.0, 0.5 * body_1.width[1]]) body_1.friction = 0.2 body_1.rotation = 0.0 world.add_body(body_1) body_2 = Body([5.0, 5.0], 100.0) body_2.position = np.array([45.0, 60.0]) body_2.friction = 0.2 body_2.rotation = 0.0 world.add_body(body_2) joint = Joint(body_1, body_2, body_2.position * [0, 1]) world.add_joint(joint) return world
def demo_4() -> World: world = World(gravity=GRAVITY, iterations=IMPULSE_ITERATIONS) body_1 = Body([100.0, 10.0]) body_1.position = np.array([0.0, 0.5 * body_1.width[1]]) world.add_body(body_1) for i in range(8): body = Body([3.0, 3.0], 1.0) body.friction = 0.2 x = np.random.rand() - 0.5 body.position = np.array([x, 12.0 + 3.5 * i]) world.add_body(body) return world
def demo_3() -> World: world = World(gravity=GRAVITY, iterations=IMPULSE_ITERATIONS) body_1 = Body([100.0, 1.0]) body_1.position = np.array([0.0, 20.0]) body_1.rotation = -0.25 world.add_body(body_1) frictions = [0.75, 0.5, 0.35, 0.1, 0.0] for i, fric in enumerate(frictions): body = Body([3.0, 3.0], 25.0) body.friction = fric body.position = np.array([-45.0 + 10.0 * i, 40.0]) world.add_body(body) return world