home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.graphics
- Path: sparky!uunet!news.smith.edu!orourke
- From: orourke@sophia.smith.edu (Joseph O'Rourke)
- Subject: Re: Point inside a triangle
- Message-ID: <1992Nov16.115211.23169@sophia.smith.edu>
- Organization: Smith College, Northampton, MA, US
- References: <7bv1svg@rpi.edu> <BxsLL1.5H5@slipknot.rain.com>
- Date: Mon, 16 Nov 1992 11:52:11 GMT
- Lines: 21
-
- In article <BxsLL1.5H5@slipknot.rain.com> robert@slipknot.rain.com.UUCP (Robert Reed) writes:
- >The standard edge crossing test, which works for any other polygon, should work
- >fine here. See page 34, Foley and van Dam Computer Graphics. In brief you
- >count the number of polygon edges that cross a ray drawn from the point to
- >infinity. An odd number of crossings means the point is interior.
-
- Although this is a matter of taste, I find this inferior to
- the algorithm that I use, which tests if the point is left-of-or-on
- the three directed lines determined by pairs of vertices of the triangle.
- In the edge crossing code, one must deal with the ray crossing a
- vertex, being parallel to an edge, being collinear with an edge:
-
- /\
- / \
- / \
- *---+------+------>
-
- Coding these special cases requires care. The other method has no
- no comparable special cases. But all methods, as someone else pointed
- out, are subject to tricky precision issues, because coordinates
- are multiplied.
-