Esempio n. 1
0
def test_simulation_discard_object():
    gravity = (0, -10.0)
    w = World(gravity=gravity)
    p = w.add.regular_poly(N=6, length=2.0, pos=(0, 0), mass=1.0)
    w._simulation.discard(p)
    w.update(0.1)
    assert p._acceleration != gravity
Esempio n. 2
0
def test_simulation_discard_object():
    gravity = (0, -10.0)
    w = World(gravity=gravity)
    p = w.add.regular_poly(N=6, length=2.0, pos=(0,0), mass=1.0)
    w._simulation.discard(p)
    w.update(0.1)
    assert p._acceleration != gravity
Esempio n. 3
0
def test_energy_tracker_default_kinetic_energy():
    w = World()
    w._simulation._kinetic0 = None
    w._simulation._potential0 = 0
    w._simulation._interaction0 = 0
    e1 = w.track.energy()
    assert e1() == None
Esempio n. 4
0
def test_energy_tracker_raises_division_by_zero():
    w = World()
    w._simulation._kinetic0 = 0
    w._simulation._potential0 = 0
    w._simulation._interaction0 = 0
    e1 = w.track.energy()
    with pytest.raises(ZeroDivisionError):
        e1()
Esempio n. 5
0
def test_simulation_enforce_max_speed():
    speed = 10.0
    w = World(max_speed=speed)
    p = w.add.poly(vertices=[(0, 0), (1, 1), (0, 2)],
                   vel=(200, 200),
                   pos=(0, 0))
    w._simulation.enforce_max_speed()
    assert p._vel.norm_sqr() > speed**2
Esempio n. 6
0
def test_energy_tracker_method():
    w = World()
    w._simulation._kinetic0 = 1.0
    w._simulation._potential0 = 1.0
    w._simulation._interaction0 = 1.0
    t = Tracker(w)
    e1 = t.energy()
    e2 = w.track.energy()
    assert e1() == e2()
Esempio n. 7
0
def test_simulation_gravity():
    gravity = (0, -10.0)
    w = World(gravity=gravity)
    p = w.add.regular_poly(N=6, length=2.0, pos=(0,0), mass=1.0)
    w.update(0.1)
    assert p._acceleration == gravity
Esempio n. 8
0
def test_tracker_energy_tracker_not_none():
    w = World()
    t = Tracker(w)
    assert t.energy()
Esempio n. 9
0
def test_simulation_gravity():
    gravity = (0, -10.0)
    w = World(gravity=gravity)
    p = w.add.regular_poly(N=6, length=2.0, pos=(0, 0), mass=1.0)
    w.update(0.1)
    assert p._acceleration == gravity