[comp.graphics] intersecting regions

elrond@titan.tsd.arlut.utexas.edu (Brad Hlista) (02/25/90)

I have two regions A and B defined by four vertices.  Letting A be the 
boundary of the screen, I am looking for a fast clipping routine to find the 
new vertices of A intersect B. I have come up with something but the number
of tests I make to check the new points continue to grow. I should mention that
the vertices of B can be anywhere in the cartesian plane and that none of the
lines from the vertices intersect other than at the vertices.  Any help would
be appreciated.

	Brad Hlista
	elrond@titan.tsd.arlut.utexas.edu

spencer@eecs.umich.edu (Spencer W. Thomas) (02/26/90)

In article <610@titan.tsd.arlut.utexas.edu> elrond@titan.tsd.arlut.utexas.edu (Brad Hlista) writes:
> I have two regions A and B defined by four vertices.  Letting A be the 
> boundary of the screen, I am looking for a fast clipping routine to find the 
> new vertices of A intersect B. 

If A is convex, then you can use the Sutherland-Hodgman polygon
clipping algorithm (see any standard graphics text, e.g. Rogers,
_Procedural Elements of Computer Graphics_, McGraw Hill).  Note that
the result may have more than 4 vertices (it can have more than 8, but
must have less than 12).

If A is concave, then you have to use a more complex algorithm (e.g.,
Weiler-Atherton polygon clipper, also described in Rogers, and also
referenced recently in this newsgroup.)

--
=Spencer (spencer@eecs.umich.edu)