Jump to content
  • Advertisement
Sign in to follow this  
bigbanggames

Convex Polygon SAT Collision

This topic is 2104 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!