note
kapper
<P>
Its not just for fun that most game programmers work strictly in triangles.. problems such as the one you mentioning becomes so much faster to calculate...
</P>
<P>
<B>Simple solution:</B> Make sure you are only dealing with triangles.. create a static point for each triangle, which you <B>know</B> is within it.. now make a line from that point to your point, check if it intersects with any of the lines in your triangle... if true, its outside, false, inside.
</P>
<P><B>Most general solution:</B> I believe this was allready mentioned, but create a line between your point and any point which you <B>know</B> is outside of the polygon.. now count the number of intersections between this line, and edges in your polygon.. if its odd, your point is inside, otherwise outside.. <I>(note: do not count intersections with edges, just ignore them... and this solution does not only work with triangles, but any polygon)</I>
</P>
<P>
<B>Alternative solution:</B> This one will also only work with triangles.. project your point onto two of the edges in the polygon. Yous should now have two fractions t1 and t2 telling you where your point projected onto the two edges.. if both t1 and t2 are between 0 and 1, and t1+t2<1 then your point lies within..
</P>
<P>
Anyways, have fun... if you need more solutions, search for pages about the nonzero <I>winding number rule</I>... I'm too tired to explain it now, but it should be easy to find a good page on it... <I>(Note: this method will also work well with polygons that intersect with temselves to generate hollow areas within.. )</I>
</P>
109325
109325