예제 #1
0
    def testCircle(self):
        c1 = Circle([0, 0], 1, vel=[0, 0])
        c2 = Circle([0, 0, 0], 1)
        c3 = Circle(torch.tensor([0, 0], dtype=DTYPE), torch.tensor(1, dtype=DTYPE), vel=torch.tensor([0, 0], dtype=DTYPE))
        c4 = Circle(torch.tensor([0, 0, 0], dtype=DTYPE), torch.tensor(1, dtype=DTYPE), vel=torch.tensor([1, 1, 1], dtype=DTYPE))
        c5 = Circle([0, 0, 0], 1, [0, 0, 0], mass=torch.tensor(1, dtype=DTYPE))

        c1.add_no_contact(c2)
        c2.add_force(Gravity())
        c2.apply_forces(1)
        c3.set_p(c3.p.new_tensor([1, 1, 1]))
        c4.move(0.1)
예제 #2
0
def make_world(learned_force):
    bodies = []
    joints = []

    target = Circle([500, 300], 30)
    bodies.append(target)

    c1 = Circle([250, 210], 30)
    bodies.append(c1)
    c1.add_force(ExternalForce(learned_force))
    c1.add_no_contact(target)

    c2 = Circle([400, 250], 30)
    bodies.append(c2)
    # joints.append(Joint(c2, None, [500, 275]))
    c2.add_no_contact(target)

    world = World(bodies, joints, dt=DT)
    return world, c2, target