Open eastskykang opened 3 years ago
I think one of the reasons should be that we suppose the object and the ground are both rigid bodies, however in reality they are both not.
The other reason may be that, we suppose the collision happens in an instant, but in reality it requires some time.
@Hustwireless @zdchan thank you very much for your participation!
Let's start from the identifying the problem. What do you notice from the demo video?
I think the most obvious ones are:
Current thoughts of this question:
when epsilon = 0: Theoretically, the ball will be on the ground and become still right after it contacts the ground, which means instantly. However, because we are using the Euler method, the velocity has to be reduced through several time steps, so the ball will travel some distance before it finally stops, and we didn't implement a correction method for it.
But we can deduce that, when dt is approaching 0, the simulation will look more and more like real. Then I tried to decrease the time step and found that the part underground will get smaller when the step size reduces. When step size = 300, the result is pretty good.
when epsilon = 0.5: Theoretically the ball should become still after a few bounces, however, we can observe that it will keep bouncing and there is no sign to stop. That's because when the time step is not small enough (actually need to be infinitely small I guess), the ball will be definitely above the ground after collision.
The collision impulse will push the ball up from the ground by a certain minimum amount due to the numerical error, which means it can't be just perfect 0 and not bounces again. On the other hand, the ball can't stop like what it does when epsilon = 0, because when the lowest point on the ball is below the ground and collision velocity is not zero, the positive epsilon will definitely provide a reverse velocity. So the ball will be above the ground after collision. Then the ball will receive the gravity pull again and fall down to collision again.
The performance is also better when time steps reduced, nonetheless the bouncing cannot be eliminated but just hard to see. We can still observe that through command line output of the lowest point on the ball.
when epsilon = 1: Theoretically the ball should stay at the same height after each bounce, however it bounces higher and higher, and this can only due to additional energy introduced in the system. So where does this additional energy come from?
We can observe that each time the ball contact the ground, the lowest point must be less than 0, because that's how we detect whether a collision happens. And this results in the ball actually gains gravitational potential energy by that little amount each time. And the gained energy is eventually converted and added to the total energy of the ball.
@Hustwireless Brilliant! :D
yes, our collision detection algorithm is too crude. Let's assume we just put the ball on the ground with zero velocity (without any penetration). In the next timestep, the ball will go down due to gravity, but our collision detection algorithm will not identify the collision since the position yet is not updated. Thus the ball will go through the ground with certain amount of penetration error. (and next timestep, eventually our collision detector will say the ball and the ground are in collision and activate impulse-based collision logic)
that's why small dt gives a better result. still the penetration error exists, but it will be small enough
Watch the following demo video and let's discuss what's problem and why it happens:
https://youtu.be/v1zMGm-7id4
Please leave your idea freely!
update: I found the title is a bit misleading. Let's focus on errorneous behaviors of our collision model. Assuming ideal case, what is expected behaviors of ball after collision? Does our simulation follow such expectation? If not, why is it the case?