Thank you for sharing your work on this 2D collision stuff. It was very clear and I was able to implement it quickly into my Java program. I have tested the technique with various parameters: 2 balls to multiple balls, different sizes, different initial trajectories, and different initial velocities. It worked well from the very beginning thanks to your clear example.

However, (didn't you know that was coming  ;)) I am having a bit of a problem. The balls seem to stick sometimes and even bounce off in odd directions. Sometimes the velocities increase at unexpected levels.

I put a test after the new locations and velocities have been calculated to see if the values were NaN's according to Java. In those cases I did not update the locations or velocities and the balls would overlap for a period of time.

I am assuming this is some kind of math precision issue. I have kept all variables at the level of Java's "double". Is there some kind of technique you employ to prevent this sort of behavior? Perhaps there's a flaw in my processing of all the balls. I "move" them all, then check each one against each other (only once, no redundancy) adjusting the locations and velocities according to your example.

Thanks in advance for any help.