home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!torn!news.ccs.queensu.ca!qucdn!jiangy
- Organization: Queen's University at Kingston
- Date: Saturday, 12 Sep 1992 22:16:54 EDT
- From: <JIANGY@QUCDN.QueensU.CA>
- Message-ID: <92256.221654JIANGY@QUCDN.QueensU.CA>
- Newsgroups: comp.graphics
- Subject: Re: 3d line through 3d polygon
- References: <BuGD8w.CxA@iat.holonet.net>
- Lines: 44
-
- The most intuitive (not necessarily efficient) solution is:
- (1) compute the coefficient (A, B, C, D) of the polygon plane
- using Newell (?) method. See Gems I (or II or III, cann't
- remember exactly) for the code.
- (2) compute the intersection point between the infinite line
- and the plane.
- (3) test if the point is in the polygon. The code for this can be
- found in the latest Raytracing news (ftp: princeton.edu, in
- pub/Graphics/RTNews/RTNv5n3).
- (4) if the answer to (3) is yes, determine if this point lies
- between the two end points of the line segment. If yes, the
- line segment intersect the polygon and the point is what you
- are looking for.
-
- Yaohong Jiang
- Queen's U
-
-
- (Sorry, I missed one step between steps 2 and 3: you have to rotate
- the polygon and the intersection point so that all the polygon vertices
- and the intersection point have the same z coordinates, since the point-in-
- polygon test in RTNews works only for 2D point and polygons.
-
- Rotating the polygon is equivalent to rotating the x-y-z coordinate system
- as following: Given a point P(x,y,z) in x-y-z coordinate system, Let
- (x', y', z') be the coordinates W.R.T the second coordinate system x'-y'-z'
- Assume the two systems have the same origin and :
- x' has direction cosine t11, t21, t32 W.R.T x-y-z system
- y' has ................ t12, t22, t32 ...................
- z' has t13, t23, t33 ...................
- ( This also means that:
- x has direction cosine t11, t12, t13 W.R.T x'-y'-z' system
- y t21, t22, t23
- z t31, t32, t33
- t11, t12, etc. can be computed from the polygon plane easily.
-
- Then we have : x' = t11*x + t21*y + t31*z
- y' = t12*x + t22*y + t32*z
- z' = t13*x + t23*y + t33*z
-
- And lastly, remember to rotate the polygon and the intersection back
- after the point-in-polygon test before the last step above.
-
- Y. Jiang
-