Langping
Langping

Reputation: 13

The result of the HelloWorld example in Bullet Physics is not consistent with free-fall law?

I think the HelloWorld.cpp of Bullet Physics gives an example of free-fall.

In order to check if the result of Bullet Physics is consistent with physics law, in the HelloWorld.cpp, I changed the initial position of the sphere from "startTransform.setOrigin(btVector3(2, 10, 0));" to "startTransform.setOrigin(btVector3(2, 0, 0));", and I changed the simulation step from "//dynamicsWorld->stepSimulation(1.f / 60.f, 10);" to "dynamicsWorld->stepSimulation(0.1f, 0, 0.1f);"

I think, after these two changes, the output will be the positions of the sphere in free-fall motion spaced by 0.1 second. I also output the linear velocity of the sphere at each simulation step. The result is: vx, vy, yz, px, py, pz

The first line is the initial linear velocity and position. We can find that, the velocity is consistent with the free-fall law (i.e., v = g * t), but the position (displacement) is not consistent with the free-fall law (i.e., s = g * t * t / 2).

So, I wonder that if Bullet Physics is reliable? Or did I get something wrong?

Thanks!

Upvotes: 1

Views: 419

Answers (2)

Joan Aguilar
Joan Aguilar

Reputation: 1

Most physics engines (including Bullet) use semi-implicit Euler integration which is only first order accurate. A free-fall equation is second order (y = y0 + vy0*t - 0.5*g*t^2, it has a t^2 term) and thus semi-implicit Euler is going to induce error.

In general, I would not expect physics engines to be extremely accurate (there are a lot of assumptions and approximations being made). However, they can be an acceptable model of reality depending on what you need.

Upvotes: 0

Mankarse
Mankarse

Reputation: 40643

I don't know much about Bullet in particular, but perhaps I can help with some general information about physics engines.

Physics engines are essentially numerical integrators. They do not produce a precise analytical solution to the kinematic equations, but rather numerically sum up the velocities at each time step to generate the positions. (And numerically sum up the accelerations/forces to produce the velocities, etc).

From the numbers that you have found, it appears that Bullet Physics is using the Euler Method for computing the integral. This is one of the least accurate methods for computing an integral, but it is also one of the simplest, both to understand and to compute.

The velocities are accurate, because the acceleration is constant, but the positions are inaccurate, because the velocity is non-constant.

Bullet Physics isn't unreliable or wrong, it is just using an approximation that isn't particularly accurate; presumably in order to have the performance to compute real-time results in complex scenes.

Upvotes: 2

Related Questions