I am creating a gas particle simulator based game. All nodes (green circles) represent gaseous particles and collide elastically.
My algorithm correctly accounts for two-particle collisions, as the final velocity are calculated by directly applying an equation. However, it fails if three or more particles are overlapping (colliding) in the same clock-time (frame).
My question is how can I calculate the final velocities of a collision with more than two particles colliding. Note that if A collides with B and B collides with C, A need not collide with C (B may be in the center).
Is there an algorithm designed specifically for this?
The momentum is incorrect (as of writing). However, the KE graph is changing its value. If the algorithm for two-particle collisions worked correctly, the KE wouldn't change. The graph is constant for most of the time but it goes up and down.