# Collisions between moving ball and polygons

I know this is a very typical problem and that there area a lot of similar questions, but I have been looking for a while and I have not found anything that fits what I want.

I am developing a 2D game in which I need to perform collisions between a ball and simple polygons. The polygons are defined as an array of vertices.

I have implemented the collisions with the bounding boxes of the polygons (that was easy) and I need to refine that collision in the cases where the ball collides with the bounding box. The ball can move quite fast and the polygons are not too big so I need to perform continuous collisions.

I am looking for a method that allows me to detect if the ball collides with a polygon and, at the same time, calculate the new direction for the ball after bouncing in the polygon.

(I am using XNA, in case that helps)

• doswa.com/2009/07/13/circle-segment-intersectioncollision.html May 1 '12 at 15:42
• That is, the key thing you're probably missing is that "polygons" are just collections of line segments. May 1 '12 at 15:42
• what do you mean by polygon that can be a rather broad term considering that a polygon can have anywhere from 3 to infinity sides? what is the concavity of the polygon. are all faces convex, or are some concave? do you want pixel perfect collisions? is the structure of the polygon know to the graphics system (are you using the directX portion, or the XNA portion) May 1 '12 at 18:32
• I am concerned about the ball moving too fast. The algorithm you are linking is very good but it covers the case when the ball is moving. May 2 '12 at 9:08
• I used a sphere tree for this. Very straightforward and works well without having to test the real geometry. Sep 5 '12 at 19:27