2D Collision Physics
I''ve got the detection part down pat, but I can''t figure out how to do realistic 2D collision between ship and asteroid.
I know the law of conservative of motion, but not sure how to apply it. I''ve searched the forum, and all mentoined kinetic energy (I know what it is), but I don''t understand it. Can someone please explain in simple steps how it works? Thanks.
Here's what I do:
Assume that both shapes are circles.
Find a momentum vector for each object (velocity scaled by mass)
Draw a line between the centers of the two circles (the "normal" line).
Use vector projection to project each objects' momentum vector onto the normal line. These represent how much momentum is transferred to the other object.
For object A, momentum = momentum - projection_a + projection_b;
For object B, momentum = momentum - projection_b + projection_a;
Find each objects' new velocity by dividing the new momentum vector by its mass.
Not entirely sure if this is 100% accurate (my equations are written with velocity and mass separated instead of momentum)
If you have more complicated objects, remember that all you really need is a surface normal vector to project momentum onto.
[edited by - Nypyren on March 4, 2003 3:01:31 AM]
Assume that both shapes are circles.
Find a momentum vector for each object (velocity scaled by mass)
Draw a line between the centers of the two circles (the "normal" line).
Use vector projection to project each objects' momentum vector onto the normal line. These represent how much momentum is transferred to the other object.
For object A, momentum = momentum - projection_a + projection_b;
For object B, momentum = momentum - projection_b + projection_a;
Find each objects' new velocity by dividing the new momentum vector by its mass.
Not entirely sure if this is 100% accurate (my equations are written with velocity and mass separated instead of momentum)
If you have more complicated objects, remember that all you really need is a surface normal vector to project momentum onto.
[edited by - Nypyren on March 4, 2003 3:01:31 AM]
You can use my code posted in this thread. Note that in my first post I made a mistake in formula for moving-to-static object collision (corrected in later post).
Hey thanks, that''s what I needed to hear 
Mass and velocity are also seperate in my program.
How do I figure out the normal line?
X1,Y1 and X2,Y2 are the two points of the normal line right?
Is that all I need to make the line or do I have to know the angle or some other info?
I think I understand the projection part.
How do I split the momentum back into X,Y?
Take the angle of the momentum and use cos and sin to apply the momentum/mass?
Thanks for your help!

Mass and velocity are also seperate in my program.
How do I figure out the normal line?
X1,Y1 and X2,Y2 are the two points of the normal line right?
Is that all I need to make the line or do I have to know the angle or some other info?
I think I understand the projection part.
How do I split the momentum back into X,Y?
Take the angle of the momentum and use cos and sin to apply the momentum/mass?
Thanks for your help!
Nevermind, I understand it now after a little researching on Advanced Bug''s code.
Thanks again!
Thanks again!
I found a problem with your physics, I notice that you add the new velocity to the ship/asteroid/whatever after colliding. This causes the both object to act like black hole, both pulling eahc other in. I changed it to subtract, and now it works perfectly! Thanks so much!

500x3







500x3
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement