home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!rpi!psinntp!psinntp!eye!erich
- From: erich@eye.com (Eric Haines)
- Newsgroups: comp.graphics
- Subject: Re: Point inside a triangle
- Message-ID: <1992Nov18.095436.27867@eye.com>
- Date: Wed, 18 Nov 92 14:54:36 GMT
- References: <1992Nov16.115211.23169@sophia.smith.edu> <Bxtz3s.6xA@slipknot.rain.com> <1992Nov17.132302.6345@sophia.smith.edu>
- Organization: 3D/EYE, Inc. Ithaca, NY
- Lines: 44
-
- In article <1992Nov17.132302.6345@sophia.smith.edu> orourke@sophia.smith.edu (Joseph O'Rourke) writes:
- >In article <Bxtz3s.6xA@slipknot.rain.com> robert@slipknot.rain.com.UUCP (Robert Reed) writes:
- >
- >>The special cases are trivial to discard, if the ray intersects a vertex, the
- >>adjacent vertices must have Y values of opposite sign (assuming a horizontal
- >>ray) to represent a crossing. If the point is collinear with an edge, discard
- >>it [the edge, I presume].
- >
- >It seems from your description that points on the boundary of the triangle
- >T are not handled consistently by the ray algorithm. Below, a is not in T
- >but b is in T.
- >
- > /\
- > b \
- > / \
- > +--a---+
- >
- >At least this seems to be what the code that Michael Goza posted does.
- >Am I right?
-
- Absolutely right - points on the edges are (somewhat) arbitrarily determined
- to be in or out by the ray crossings test. The good news is that there is
- consistency: if a point lies on an edge shared by two polygons, the point
- will be found to be inside one and only one polygon when you use the ray
- crossings test. This is an excellent property for rendering and picking, as
- you generally want to consider any point on a surface as being inside one and
- only one polygon.
-
- By the way, to absolutely maintain this consistency property you have to make
- sure to project all polygons in the same fashion (i.e. you can't just use the
- "cast onto the best plane for this polygon's normal" idea mentioned). Usually
- this consistency does not matter for well-behaved polygons; only when
- (ill-defined) non-planar polygons are being rendered is it important to be
- consistent in the way the 3D polygons are projected to 2D.
-
-
- Incidentally, all you point-in-triangle posters might want to check out the
- FTP site princeton.edu [128.112.128.1], file /pub/Graphics/RTNews/RTNv5n3.Z,
- the latest issue of the Ray Tracing News, which is dedicated to the point in
- polygon question (though there's still more to be written - next issue...).
- There is efficient code for the crossings test (it's a bit faster than the
- code Mike Goza posted), the barycentric test, and more.
-
- Eric Haines
-