Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!ucbvax!ucbvax.berkeley.edu!nj From: nj@magnolia.Berkeley.EDU (Narciso Jaramillo) Newsgroups: comp.sys.amiga.programmer Subject: Re: Clicking on irregular shapes? Message-ID: Date: 5 Apr 91 18:46:54 GMT References: <1991Apr05.104141.2118@cs.ruu.nl> Sender: nobody@ucbvax.BERKELEY.EDU Organization: Postcarcinogenic Bliss, Inc. Lines: 43 In-reply-to: ptavoly@cs.ruu.nl's message of 5 Apr 91 10:41:41 GMT In article <1991Apr05.104141.2118@cs.ruu.nl> ptavoly@cs.ruu.nl (Peter Tavoly) writes: > /\ > / \ /\ > / O \ / \ X > / \/ ___\ > /_______ / > \/ >where you draw the horizontal line from the 'O' to the 'X', now, it intersects >an odd number of boundaries, yet it is OUTside the shape. Er, from your diagram, it looks to me as if the O is INSIDE the shape. If you mean that the two `mountains' are separate shapes, then presumably the boundaries of each are represented separately. So you should only check the intersection against the boundaries of the polygon you're interested in. > imagine a shape like this: > > /\ b > / \ / > / O \c / X > / \/ > /_______/a >Here, an even number of boundaries is crossed. (The second intersection is a >single line) This is only a problem if you represent that odd line as only one line. Since it's a closed polygon, it makes a little more sense to represent it as two lines--one going from the point I've marked `a' to the point I've marked `b', and another going from `b' back down to `c'. I just realized that you may be assuming that this test works with raw bitmaps. In general, it only completely works if you have an internal representation of your polygons. If you're only working with a bitmap image, this won't work so well in degenerate cases. It's probably better to go ahead and represent your polygons internally--a simple array of line endpoints won't take up much room. nj