Xref: utzoo comp.graphics:1876 comp.sys.ibm.pc:12713 Path: utzoo!dciem!trigraph!michael From: michael@trigraph.UUCP (Michael Winser) Newsgroups: comp.graphics,comp.sys.ibm.pc Subject: Re: COMPLICATED PROBLEM; ONLY INTELLIGENT PEOPLE SHOULD READ Message-ID: <384@trigraph.UUCP> Date: 3 Mar 88 15:27:36 GMT Article-I.D.: trigraph.384 Posted: Thu Mar 3 10:27:36 1988 References: <971@ut-emx.UUCP> Reply-To: michael@trigraph.UUCP (Michael Winser) Organization: Trigraph Inc., Toronto, Canada Lines: 29 In article <971@ut-emx.UUCP> jezebel@ut-emx.UUCP (Jim @ MAC@/) writes: >Have a nice one here: >Have a boundary defined on the screen. Boundary is composed of points >joined by lines... Now some random points are generated and I want to check >if a given point is within or outside the existing boundary.. Any algorithm for >this ? Is it at all possible ???? >Running with GKS....under Fortran... >Mind-boggling for you ? If not, you are the guy/gal who has the >solution to my problem..... >Please respond..... >Jim All you have to do is "draw" a line from the given point to a point known to be outside the boundary, then see how many times that line intersects with the set of lines that make up the boundary. If the number of intersections is odd then your point is inside the boundary. You must also check for the special case of the intersection occuring at one of the boundary points, such a point must only be counted once. GKS may have some nice routine defined that does this for you, but I'd be quite surprised. Michael -- ...mnetor!utzoo!trigraph!michael Michael Winser michael@trigraph.UUCP Trigraph Inc. 5 Lower Sherbourne St. #201 (416) 363-8841 Toronto,Ontario M5R 3H8