Ok, I think the picture is becoming more clear. If you were simulating unconstrained rigid bodies (no interaction, no friction), you could directly use the equation for motion.
Ignoring contact and joints, if you wish to simulate drag (where the force of drag is proportional to the velocity, aka the rate of change of velocity depends on the current velocity), you have an ODE:
So the problem with drag is that it is very difficult to analytically integrate. However, if you use Euler's method (with small enough timesteps) we can numerically integrate the function and generate an approximation.
Code: Select all
a = 0; // start the frame with no acceleration
a += g; // add the force of gravity -9.80
a += C * v; // add the velocity times the drag coefficient (C)
v += a * t; // euler integrate for velocity over time (t)
r += v * t; // euler integrate for the position (r) over time (t)
I can see why Euler's method is not good for large timesteps because while the drag is continuously changing (drag is getting smaller at the same time as velocity is getting smaller), Euler's method treats it as a constant over the timestep. This error is compounded with the fact that the velocity is also continuously changing and is also treated as constant.
My calculus skills are pretty weak, I would understand more clearly if someone could help me derive the general solution for this simple drag scenario I have depicted above. Then I could compare the analytical solution with an Euler approximation for shrinking values of t.
Ah, I see even for this simple example
Wikipedia reveals the difficulty of finding a general solution.
After that, it becomes even more complicated (joints and contact) because computing those forces depends on the positions and physical characteristics of the other bodies?