Date: Wed, 4 Nov 1998 16:51:20 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: a j cc: djgpp AT delorie DOT com Subject: Re: point detection in triangles In-Reply-To: <19981104121444.28324.qmail@hotmail.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com 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".