• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

# Convex Polygon SAT Collision

### #1bigbanggames  Members   -  Reputation: 142

Like
0Likes
Like

Posted 11 October 2013 - 09:17 PM

I am working on a game using MonoGame. I need to use convex polygon to convex polygon and convex polygon to circle collisions. I have done some studying on The Separating Axis Theorem. I have a couple of general questions, mainly revolving around implementing this algorithm in C#.

I was planning  on storing a line segment of a polygon as a startingPoint and endingPoint using Vector2 data types. I was then going to implement the left normal as a Vector2.

1. Do I need to normalize the left normal before getting my projections?

2.Could I use a float for the left normal? Would this be easier or harder to implement?

3.Should I use a Vector2 for the polygon line segment?(instead of the of the two points as Vector2's)

### #2RnaodmBiT  Members   -  Reputation: 285

Like
0Likes
Like

Posted 12 October 2013 - 03:59 AM

I made a half-baked physics engine a few years back using C# and XNA. When I did it I stored all the points of the polygon in a simple list, such that p0 -> p1 formed an edge and p1 -> p2 formed the next edge. You just have to make sure they are all clockwise or counter-clockwise otherwise you will end up with weird shapes.

In 2D space the normal of a line is another line perpendicular to it. So using this you don't actually have to store the normal, you can determine it from calculations as you need it, but it will need to be as a Vector2 as that is the correct way to do the projections you will need.

PARTNERS