Mail Archives: djgpp/1998/11/04/10:00:22
On Wed, 4 Nov 1998, a j wrote:
> can anyone explain how you detect if a point is
> inside or outside a triangle.. in a simple 2D x-y co-ord system.
Draw a line from the point in any direction. If it crosses the sides of
the triangle an odd number of times, the point is inside; otherwise, it's
outside.
Depending on whether you care, there are some borderline cases when the
point is exactly on one of the sides.
> or offer some C code.. or a reference for places to get this info.
I think I posted a general solution (good for any polygon, not just a
triangle) a year or so ago. Try searching the DJGPP forum archives at
http://www.delorie.com/djgpp/mail-archives/ for words like "polygon".
- Raw text -