Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
183 views
in Technique[技术] by (71.8m points)

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

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.

question from:https://stackoverflow.com/questions/65837306/why-disabling-world-gravity-has-no-effect-on-moving-rigid-body

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...