Jump to content
  • Advertisement


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.

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

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

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!