Jason
Jason

Reputation: 4034

Collision detection with oddly shaped polygons

I am planning to make a program which will have some circular shapes moving inside of a oddly shaped Polygon.

I can't seem to figure out how to do the collision detection with the edges and have the shapes bounce back correctly.

I am sure this problem has been solved before, but I can't find a nice example.

My main problems are: Figuring out if the circle has hit the edge of its surrounding polygon. Once a hit occurs calculate the normal of the hit point to figure out the reflection vector.

Can anyone point me in the right direction?

Thanks, Jason

Upvotes: 0

Views: 484

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328770

You need to do a circle line intersection test.

To make it faster, you can first check the bounding boxes. For example, if the start and end point of the line are both to the left of the leftmost coordinate of the circle, there can't be an intersection.

Upvotes: 1

Related Questions