• Create Account

## 2D Polygons

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1Freeride Designs  Members

122
Like
Likes
Like

Posted 21 December 1999 - 11:29 AM

I'm programming in directX 7 and VB.
Does anyone know how to draw a texture inside a polygon.

Some other info on whether a point is within the polygon etc. would be helpful aswell

Thanks

### #2QWERTY  Members

122
Like
Likes
Like

Posted 21 December 1999 - 11:29 AM

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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.