# Calculating collision of polygons

Say I have a multitude of 2D polygons floating about on a plane. These polygons can have any side count and aren't necessarily regular.

Assuming I know absolutely everything about the polygons (area, collision point, location, velocity, rotation, angular velocity... etc) how to I calculate what happens to two polygons after collision?

I.e. what will their resultant velocities and angular velocities be after collision? If not an exact solution, what resources could help me learn how to accomplish this?

This is kinematics, which allows us to deal with each kind of motion (rotation, translation) separately.

First of all, let's look at the what the new direction and velocity of the 2 object is going to be. We need the normal of the side the collision happens on to get the direction. Given the normal (yellow), the direction of object A (green object, green vector) and object B (red object, red vector) is (black is the original velocity) (the red object is considered static in this example. To get the dynamic-dynamic collision's result, do the same calculation twice and add the direction vectors together): Basically you get the new velocity of object B by projecting object A's original velocity on to the negative version of the normal and you get A's new velocity by dividing B's new velocity from A's original velocity. To get the result, as I wrote above, do the same with A being static and add the resulting velocity vectors together.

This should solve the translation problem, now onto rotation.

Every object has angular momentum, even if it doesn't rotate. It can be expressed as

L = m * v * r * sin(theta)


where m is the mass, v is the velocity of the dynamic object (again, if both of them are dynamic, simply do these twice), r is the distance of the center of masses and theta is the angle between the vector pointing from the dynamic body to the static body and the velocity vector. You can simplify this to get an angular velocity:

ω = m * v / (1/3 * M * r * sin(theta))


where M is the mass of the static object. Now take this angular velocity and add it to the current angular velocity of the static object and you're done.

Sources:

angular momentum: https://en.wikipedia.org/wiki/Elastic_collision