#### Archived

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

# 2D Collision Physics

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

## Recommended Posts

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.

##### Share on other sites
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]

##### Share on other sites
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).

##### Share on other sites
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?

##### Share on other sites
Nevermind, I understand it now after a little researching on Advanced Bug''s code.

Thanks again!

##### Share on other sites
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

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5
frob
12

• 9
• 21
• 13
• 9
• 17
• ### Forum Statistics

• Total Topics
632608
• Total Posts
3007391

×