Sign in to follow this  

2D Collision Response - No rotation ?

This topic is 4512 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

Hi, my brain is hurting. I'm trying to find out how to do acceptable collision response between two polygons. Most of the pages found by using Google are too confusing for my simple math skills or deal with rotations also. I'm not interested in rotation for gameplay reasons. I'm simply hoping that some one can give me formula where I can plug in some numbers and then by magic I have the resulting velocities. Hopefully I can try to understand later. Suggestions on tutorials or easy to read books which cover these things are also welcome. But I'm a bit impatient so help is appreciated. Ok. This is known about my objects: My objects are 2D polygons. Collsion occurs between a point on object A and an edge on object B. Each object have a mass(scalar) and velocity(vector) (and thereby momentum). I know the impact point and I can calculate the edge normal. so now what?

Share this post


Link to post
Share on other sites
use "Newtons law of restitution for instantaious collisions with no friction"

if the objects are A and B

the relative velocity = Vrel = VA-VB


"Newtons law of restitution for instantaious collisions with no friction" is

dot(V2rel, N) = -e * dot(V1rel, N)

where V2 is the velocity after the collision and V1 is the velocity before
and e is constant standing for elasticity or coifecient of restitutuion

the impulse in entirely in the direction of the normal
because of this we can express the impulse as some number j time the normal,
giving j*N


since forces are equal and oppisite the impulse felt by B is -j*N

we have

V2A = V1A + j/ma*N
V2B = V1B - j/mb*N

since j is a moment and we need velicity so we solved by dividing by mass

as above exept replace rel with the vectors

dot ( V2A - V2B, N ) = -e * dot( V1A - V1B, N)

and we want to solve for j our impulse magnitute

after subsitution equation we get
dot(VA1, N) + dot(j/ma*N, N) - dot(VB1, N) + dot(j/mb*N, N) = -e * dot(V1A - V1B, N)

and solve for j

j = (-(1+e)*dot(V1A-V1B, N))/(|N|^2*((1/ma)+(1/mb))))


now just do

VA += N*j
VB -= N*J

this is pretty much straight from the chris hecker stuff. so if you dont get i suggest reading it. Just google "Chris Hecker Physics"

Share this post


Link to post
Share on other sites
That works for any kind of rigid bodies (polygons or not), and ignoring rotations.

assumptions :
object (0) has mass 'm0', velocity 'v0' and colliding edge 'e0'.
object (1) has mass 'm1', velocity 'v1' and colliding vertex 'p1' (unsused).

edges in polygons are ordered counter-clockwise. If not, the normal will be pointing inwards in polygon 0.


// normal of collision,
// in this case, a vector perpendicular to edge direction 'e'.
vector n(-e0.y, e0.x);

// make vector length = 1.0f (important)
float n_length = sqrt(n.x*n.x + n.y*n.y);
n /= n_length;

// relative velocity
vector v = v1 - v0;

// impact velocity, or how much 'velocity' going against the edge
float vn = v.DotProduct(n);

// objects are separating, no impulse.
if (vn > 0.0f) return;

// coefficient of retitution (in range 0, 1), or how much 'bounce' you want
float restitution = 0.5f;

// collision impulse
float j = (-(1.0f + restitution) * vn) / ((1 / m0) + (1 / m1));

// apply the impulse to the object's velocity.
v0 -= (j / m0) * n;
v1 += (j / m1) * n;



This is pretty much what raymond wrote, in another form.

Share this post


Link to post
Share on other sites
Thanks guys, I'm at work now, but I will look at it when I get home.
If what you wrote works I will write you into my will :)

I did come across Cris Hecker but I seem to remember that he wrote on his website that the pdf documents messed up notations so for that reason I skipped it. Being inexperinced with math and physics I could probably not detect those errors.

I even have "Physics for game developers" but I thought it was a bit difficult to follow. When I get the time I must read it from start to finish or buy another book. Just learning the basics of motion, momentum etc. is actually more interesting than I thought.

Thanks again, I really hope it works. I've been stuck for weeks because of this.

Share this post


Link to post
Share on other sites

This topic is 4512 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