Elastic Collision recommendations

Hi everyone,

I was looking for a reference to implement a simple elastic collision system in 2D. I found this thread, which points to a really awesome material regarding Real Time Collision

Recommendations for 2D collision physics references

That will be great for later, but at this point I just want to follow up on the simple and traditional formulas Elastic Collision, if you scroll down to the bottom you will find the 2D solution of the problem.

They mention two possible solutions, one using angles and other using dot product(which in the end uses another angle anyways).
Any other recommendation you would suggest me?

Feel free to extend the discussion to 3D as well, I might use that too later, at this point I just need the 2D version.

Appreciate any help.

Have a nice one!

Edited by itzjac on Reason: Initial post
I don't know what you're looking for exactly but you can search the forums for GJK (collision detection algorithm) and you'll find some resources.

Rigid body dynamics by Chris Hecker should be good (but I never read them).
Will take it from there. Thank you

Edited by itzjac on
Chris Hecker's rigid body dynamics is good, he derives the formula for impulse resolution, which has a coefficient of restitution, which when one gives the elastic rebound effect (i.e. no energy is lost in the collision.) The equation derived is also in Ian Parberry's 3D math primer for graphics & game development, which I found a bit easier to follow.

Chris Hecker's article assumes you have some way of detecting when there is a collision, and requires you have two bits of information: 1.the normal of the surface you hit and 2. the point of impact (only required when shapes can have angular momentum).

I think the hardest part is the actual detection of collision and returning the information needed for the resolution. The best solution I've fount is Erin Catto's GJK implementation . The source code is on the box2d site under downloads. And I think it is the method used in Box2D.

Note: this is different to Casey's use of GJK. Casey's method gives you a yes/no answer whether something is overlapping, whereas Erin's gives you the information you need to solve the collision resolution equations (point of collision, and surface normal).

NOTE: You can use Casey's method with the EPA algorithm to resolve a collision (i.e. not overlap anymore) and find the surface normal, but from what I know, you can't get the Point of Collision from it.

Edited by Oliver Marsh on
Thanks Oliver.

After looking at the documents I choose to start with the Box2D examples, they seem to be the most complete.

But jeez!!! Talking about distribution, getting the Box2D Testbed working is a huge pain.

I am not sure if I was too stupid to simply compile the Box2D out of the box, as is from github.
The amount of dependencies is ridiculous: freglut, glew, glfw, glui and yet you have to add manually the asset to run the executable independently. :( :(
The CMake files contain some errors and std::min, std::max functions have to be undef to work along with Windows.h.
Sad and done!

I am sharing you the example compiled for windows in case you would like to try it out. A good chance to earn community's trust, you will get to know is not a surprise:

Box2D Testbed

This is a great start, enjoy the samples they are worth just watching :)
Tiles

PS: Is it possible to add images to this forum and share links to the uploaded images? What is it used the img tag then?

Edited by itzjac on
Not sure what kind of Box2D you were compiling, but code on GitHub is built with premake, not cmake. It includes all the dependencies in source. And I don't know where you are seeing freeglut. It uses only glfw to create window.

Also reminder for people to be careful when running random binaries found on internet.

Edited by Mārtiņš Možeiko on
We are in the same page GitHUB Box 2D, but with different branches.

I downloaded from the release page Box2D releases, which I expected to be the most reliable and stable version(s), those indeed contain CMake and dependencies, but have several errors in the CMakeLists files.

I guess for the next I better live with the newest and use premake, (not sure really :S).



Edited by itzjac on
Well... last "release" was in on Apr 5, 2014. Not sure what you expected there :) I guess if you would use same tools, same versions (cmake, VS, etc...) as in 2014 then everything would compile without errors.

Usually git master will be most stable and reliable code, as most bugs are fixed there and code updated to work with latest OS/tools and not in old releases.

Edited by Mārtiņš Možeiko on
Thanks mmozeiko.

I must admit this was due to biased opinions, the last projects we usually have master with the latest but not stable.

It is way easier with premake, just a min to get all running.
It still had an error, complaining with the default SDK, but switched to the one I have installed and no errors and, one of the previously mentioned dependencies, a data folder to execute the game stand alone, is still in latest :(

Now finally, time to study the physic's code am interested.