Jump to content

Vatti clipping algorithm

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Angusj (talk | contribs) at 13:07, 12 June 2010 (Description: added link to boolean clipping). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The Vatti clipping algorithm[1] is used in computer graphics. It allows clipping of any number of arbitrarily shaped subject polygons by any number of arbitrarily shaped clip polygons. Unlike the Sutherland–Hodgman and Weiler–Atherton polygon clipping algorithms, the Vatti algorithm does not restrict the types of polygons that can be used as subjects or clips. Even complex (self-intersecting) polygons, and polygons with holes can be processed. This algorithm is generally applicable only in 2D space.

Description

Clipping is defined as the interaction of subject and clip polygons. While clipping usually involves finding the intersections (or regions of overlap) of subject and clip polygons, clipping algorithms can also be applied to the other boolean clipping operations: difference, where the clipping polygons remove overlapping regions from the subject; union, where clipping returns the regions covered by either subject or clip polygons, and; xor, where clipping returns the regions cover by either subject or clip polygons except where they are covered by both subject and clip polygons.

The Vatti algorithm involves processing edges, from both the subject and clipping polygons, in an orderly fashion starting with the lowermost edges and working towards the top. The problem space is divided by scanlines, horizontal lines that pass through every vertex of the participating polygons. These scanlines make up scanbeams - the spaces between adjacent scanlines. These scanbeams are processed in turn, starting with the lowest scanbeam, with the algorithm adding the points of edge intersections into the solution polygons.

See also

References

  1. ^ "A generic solution to polygon clipping", Communications of the ACM, Vol 35, Issue 7 (July 1992) pp. 56–63.