Sign in to follow this  

2D collision of 2 circular objects (fully elastic collision)

This topic is 4205 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im currently makin a simulation of ball's on a table see: www.mdk-photo.com/javascript/Vector anyways, so far i've used the sentence that "two objects colliding exchange their vectors of heading" <-- this is UNTRUE in 2d or 3d so now i've used 6 days on Google, Wiki and good knows where else, searching for physical formulars and vector-math without result... then i came across: http://www.gamedev.net/community/forums/topic.asp?topic_id=390861&whichpage=1� however, the math described in the post, is rarther un-readable (in my eyes) so i humbly reqeust someone to give explain or write how exactly to implement the exhange of vector-forces im sooo tired of standard physical explanations without examples :( you may start with: -before collision: vA,vB "Movement vector directions - Array[x,y]" -positions: pA,pB "Array[x,y]" extras: -Mass = 1.0 -accelleration = 0.0 (or 1.0 ?) in advance - Thanks

Share this post


Link to post
Share on other sites
Well, i used the reflection off the normal of the other ball, or do want something more discriptive, i.e. code, cause i did the sphere collision stuff in POV-Ray(a pain to code), i could probably make it into javascript.

BTW, nice smooth simulation, it's hard doing that in javascript, i did a game once, but it sucked.

Share this post


Link to post
Share on other sites
I've already proven that I'm bad at explaining this, but I'll try again anyways. The key idea is to switch the momentum in the axis of collision or exchange their vectors of heading, however you want to say it. This means finding each object's speed along that axis and switching them. The axis of collision, as I like to put it, is the axis created by connecting the 2 centers of your circles. Since it isn't likely to be aligned with your x or y axis you'll have to project your momentum's onto it before you can switch them. You can do this using the dot product ie (momentum).(normalized axis) = (magnitude of momentum along that axis). Once you have projected your momentum's you'll have 2 magnitudes one for each circle. Take these and multiply them by your axis to get 2 vectors one for each circle. Those vectors represent each of your circle's momentum's along that axis. Then for each circle subtract its vector along that axis and add the other circle's vector along that axis. That is how you "exchange their vectors of heading". Just to be clear: normalize means set a vector's length to 1 by dividing by its length and if you don't know about the dot product you should check this out: http://en.wikipedia.org/wiki/Dot_product

Hopefully, this is more helpful than last time. Someone should submit a good article on this so it doesn't come up on the forums so often.

edit: you might want to set a maximum on the text and collision checking in your program. I accidently left it running and just noticed because it was taking all of my processing power and slowly counting up on memory usage

[Edited by - Alrecenk on June 9, 2006 11:38:05 PM]

Share this post


Link to post
Share on other sites

This topic is 4205 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this