Advertisement

Convex Polygon SAT Collision

Started by October 12, 2013 03:17 AM
0 comments, last by RnaodmBiT 11 years, 4 months ago

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)

thanks in advance!

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.

This topic is closed to new replies.

Advertisement