[comp.lang.c++] Multiple-unknown-interacting-objects

davidm@uunet.UU.NET (David S. Masterson) (10/25/90)

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'/
			  -----