Skip to main content
GameDev.net gamedev.net
🔒 Locked

Simple Circle physics

Started by Dakiar Oct 10, 2006 at 5:36 AM 2 replies 1.1k views
Original Post
Dakiar
Dakiar
I have two moving cicles that collides with each other. They both have a velocity and I want them to bounce of each other. The collision is no problem, but I have been struggling to get the bounce code right! The mass of the circles are the same, so I suppose it doesn't need to be considered. I know there's a rather simple formula to do this, though my physics skill is very limited! If anyone knows the code to do this, or would like to try and help me, I would be very happy! Thank you. Dak
deffer
deffer
In case of circles, you do not have to include torque, it's just a case of getting velocities right.

The key is to decompose velocities with regards to collision normal(1).
V = Vo + Vp;
where Vo is orthogonal to collison normal and Vp is the rest (abs(dot(Vp,normal))==length(Vp)) - Vp is perpendicular to the normal vector.
In case of circles, the normal is always normalised difference of circles' centers.

Then the orthogonal component can be left alone, and you deal only with the perpendicular components - and the problem becomes 1-dimensional!
In case of bodies having same mass, all you have to do is to swap 1D velocities.

So, having:
N - collision normal.
V1 = V1o + V1p;
V2 = V2o + V2p;

We get after the collsision:
V1' = V1o + V2p;
V2' = V2o + V1p;



(1)
Decomposision proceeds as follows:
Having:
V,N
we calculate:
Vo = V - N*dot(V,N)
Vp = V - Vo
Dakiar
Dakiar
Thanks a lot! Will try to implement it today and we will see how it goes :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.