Path: utzoo!telly!attcan!uunet!cimshop!davidm From: cimshop!davidm@uunet.UU.NET (David S. Masterson) Newsgroups: comp.lang.c++ Subject: Re: Multiple-unknown-interacting-objects Keywords: An elegant technique? Message-ID: Date: 24 Oct 90 17:05:15 GMT References: <315@pcad.UUCP> Sender: davidm@cimshop.UUCP Distribution: comp Organization: Consilium Inc., Mountain View, California. Lines: 33 In-reply-to: jim@pcad.UUCP's message of 23 Oct 90 18:41:16 GMT In article <315@pcad.UUCP> jim@pcad.UUCP (James Kuzeja) writes: The premise is this: I need to determine if two shapes intersect. Of course, the exact type of shape is not known at compile time, and extensibility of the shape class is a must. I seem to remember that one technique for establishing the intersection of two shapes is to find two points on one of the shapes where the first point lies outside the area of the second shape and the second point is inside the area of the second shape. This would seem to suggest that: 1. There needs to be a virtual function on the Shape class that given a point would return whether the point is inside or outside the shape. 2. Each shape needs a function that could interate over the points in the perimeter of the shape and call (1) for each point. As soon as two points meeting the criteria above are found, then return that they intersect. This two should probably be a virtual function. Sound reasonable? -- ==================================================================== David Masterson Consilium, Inc. (415) 691-6311 640 Clyde Ct. uunet!cimshop!davidm Mtn. View, CA 94043 ==================================================================== "If someone thinks they know what I said, then I didn't say it!" __(__ / @ @ \ ( V ) Boooo... \`MMM'/ -----