This topic is now archived and is closed to further replies.

2D Polygons

This topic is 6567 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 really don't know how to draw a texture inside a polygon. But if you want to know about point containment, there are a number of ways to approach the problem, but one of the most straightforward is the half-space test. Basically, if the polygon you're testing is convex, you can think of each side as a segment that is colinear with an infinite plane. Each plane divides space into two half spaces. If the point you're testing is on the interior side of each half-space, the point must be within the polygon because of the convex property of the polygon. Thus, all you need to do is figure out a way to test if a point in 2D space is on one side of a line or the other. This isn't too bad, assuming that you label the lines in some order and convert them to vectors. Then you'll think of each of the line segments as a plane. Using the dot product operator, you can determine if a point is on either side of each plane or on the plane itself. This is the basis of the algorithm.

Share this post

Link to post
Share on other sites