I have some questions about inertia and applying rotational impulses. Here's a unit test* that is failing, and I don't understand why:
I'm assuming that ApplyAngularImpulse is used just like ApplyLinearImpulse, only for rotation instead of velocity. Looking at the b2Body code, I see that angularVelocity will not be modified when inertia is zero, but in fact, inertia is zero in my test. So, why is inertia zero, and what can I do to correct that?
* The code is written in Python 2.7.2 with PyBox2d 2.1b1, but it should be readable even if you don't know Python.
Code:
def test_apply_angular_impulse():
from Box2D import b2World
world = b2World(gravity=(0,0))
body = world.CreateDynamicBody()
assert body.mass == 1 # passes because the default body mass is 1
assert body.angularVelocity == 0 # passes because by default the body is not rotating
assert body.inertia == 0 # passes (why?)
body.ApplyAngularImpulse(1.0) # apply a small impulse that should cause the body to rotate
world.Step(1/60.0, 10, 10) # update the world
assert body.angularVelocity != 0 # fails (why?)
from Box2D import b2World
world = b2World(gravity=(0,0))
body = world.CreateDynamicBody()
assert body.mass == 1 # passes because the default body mass is 1
assert body.angularVelocity == 0 # passes because by default the body is not rotating
assert body.inertia == 0 # passes (why?)
body.ApplyAngularImpulse(1.0) # apply a small impulse that should cause the body to rotate
world.Step(1/60.0, 10, 10) # update the world
assert body.angularVelocity != 0 # fails (why?)
I'm assuming that ApplyAngularImpulse is used just like ApplyLinearImpulse, only for rotation instead of velocity. Looking at the b2Body code, I see that angularVelocity will not be modified when inertia is zero, but in fact, inertia is zero in my test. So, why is inertia zero, and what can I do to correct that?
* The code is written in Python 2.7.2 with PyBox2d 2.1b1, but it should be readable even if you don't know Python.