Page 1 of 1

Multiple sphere collision response

Posted: Wed Mar 02, 2011 4:24 pm
by JP
Hi dudes.

So I'm toying around with writing my own physics 'engine' and am currently working with spheres colliding with each other.

I found an articles which gives a seemingly great way of handling two spheres colliding with each other and correctly bouncing off each other.

But when more than two spheres collide with each other it all goes to heck and a handbasket and the spheres start intersecting with each other... floating like helium balloons and generally spazzin out bit time stylee...

Googling I have been unable to find any articles explaining how to do multiple sphere collision response... I have been told, and am finding myself, that it's a much much much bigger problem to solve when you add in extra spheres...

I'm surprised that there's nothing out there that I can find... Does anyone know of any articles that might help?

Here's the article that showed me how to do two spheres colliding: http://wp.freya.no/3d-math-and-physics/ ... -response/

Note that they have three spheres in their test app but they've engineered it so they never collide all at the same time... sneaky beggars!

Posted: Wed Mar 02, 2011 5:47 pm
by CuteAlien
Maybe search for open-source billiard games. Those should implement such collisions. But purely guessing I suppose each sphere will have to add some force-vectors for each sphere against which they collide to find their final force-vector acting on them. This alone won't prevent collisions yet, but it should at least guarantee they are outside each other again within a few calculation steps. But maybe I'm too naive there :-)

Posted: Wed Mar 02, 2011 8:17 pm
by JP
Yeah clearly there needs to be some accumulation of the resulting velocities from all the collisions but not sure how to calculate those... An industry expert in physics I spoke to said it's a crazy problem so I probably don't stand much hope!

But yeah, a billiards/snooker/pool game is a good idea to search for!

Posted: Thu Mar 03, 2011 9:09 am
by JP
Right so after a bit of searching I found this likely candidate: http://foobillard.sourceforge.net/

open source in C for Linux and Windows. The code is horrific and I'm not convinced of their solution but it seems to do the trick well enough!