Why disabling world gravity has no effect on moving rigid body?

208 views Asked by At

I am building a sandbox for playing around and testing ammo.js (a javascript port of the Bullet physic engine v2.82). So this question should apply to both Ammo and Bullet I guess.

I am starting my scene with a falling sphere and the world gravity is set to (0, -9.8, 0). Before the sphere touch the ground, I am disabling the world's gravity:

physicsWorld.setGravity(new ammo.btVector3(0, 0, 0));

I am expecting the sphere to "freeze" it's movement, since no gravity should be applied anymore, but the sphere is still falling and hit the ground. I am wondering why.

1

There are 1 answers

0
AlexB On BEST ANSWER

It's due to inertia. The first Newton's law says that if the forces applied on an object is zero (the case of your sphere after your gravity change), the acceleration is zero. But it does not mean that the velocity is null. In your case, the velocity will stay constant. Another way to convince you is with Newton's second law which is probably coded in ammo.js:

ma = F

a is the acceleration, m the mass, F the sum of external forces.

Let's say that a = (v_{t+1} - v_t) / dt. With F=0, you will get v_{t+1} = v_t, a constant velocity.

v is the velocity, dt the time step.