I'm working on a 2d physics simulation. It's a continuous time simulation, that is, it uses swept shapes over the time-frame and geometrical/vector 'analysis' to determine most immediate time of contact. The world is then stepped forward to that point and collisions are resolved before proceeding to step the world forward to the next time of collision.
I do not use relaxation techniques or any kind of intersection resolution. The objects are moved to contact states and contact events are resolved as collisions.
I have tried a CONTACT_RANGE of 0.001f down to 0.00001f. This value determines whether objects are in contact. Lowering this value leads to less overlap states, but presumably at some point, lowering the value further will lead to the simulation missing contact events because inaccuracies will lead to the systems of bodies being stepped into the discrete or overlap state.
Now, to the problem, the simulation seems to compute the outcome of collisions between 2 bodies (circles in the case I'm looking at), correctly. But I have not correctly dealt with 3 or more bodies being in contact.
In the past, I did not deal with momentum / KE correctly, but I did constrain velocities such that multi-body systems would not intersect in the next sub-frame. But now that I have a correct solution to 2 body collision, I want to do it properly for more bodies.
I'm not sure how to proceed. I have read an interesting suggestion, that in reality, no collisions are simultaneous, and they can be dealt with one after the other. Is this true ?
Could I simply compute the resultant velocity of a body from one contact, then do the same with the next contact etc?
And would that lead to the same solution as though I computed velocity in one step, from all contacts simultaneously?
Or do I need a single function for solving the velocity from multiple contacts?
Any guidance is appreciated.
Gavin
Answer
As your read suggestion suggested, you can approximate physical reality with "no collisions are simultaneous". The reason is that the physical world is full of indeterminacies (AKA errors) due to thermal fluctuations and many other sources. What this means is that, even if the strict mathematical solutions that you will find by assuming simultaneous collisions versus assuming random collisions (treating all collisions that your algorithm thinks are simultaneous as happening in random order) could differ, the "physical" behavior of the system will not change in any meaningful way. No human could tell the difference between the two. In conclusion, you are safe in treating the system of collisions as non-simultaneous, and the consequences will be undetectable for the human eye (including any real physicist's real world measurements)
No comments:
Post a Comment