#### Archived

This topic is now archived and is closed to further replies.

# 2D vector collision response

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

## Recommended Posts

These are the equations I've come up with, please respond with comments, corrections, etc.. Basically these are the equations given by Chris Hecker in his 3rd article on Rigid Body Dynamics, minus the rotation segment. the CVector class I'm using here is from http://www.cfxweb.net/~baskuene/vector.htm

void bounce(object &a, object &b)
{

float e = coef;
float m1 = a.mass;
float m2 = b.mass;
CVector C;
C.x = centerx(a) - centerx(b);
C.y = centery(a) - centery(b);
CVector Vab = a.velocity - b.velocity;
CVector n = GetNormal(C);

float impNumerator = -(1+e)*(Vab % n);
float impDenominator = ((n*(1/m1 + 1/m2)) % n);
float impulse = impNumerator / impDenominator;
a.velocity += n*(impulse/m1);
b.velocity -= n*(impulse/m2);

}


*Just in case you're confused, the CVector class has an inlined modulus operator returning the dot product. Edited by - eotvos on March 20, 2002 1:23:39 AM

1. 1
Rutin
24
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 19
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631762
• Total Posts
3002180
×