Polygon Rectangle Clipping

From CGAFaq

Jump to: navigation, search

To clip a polygon against an axis-aligned rectangle, use the Sutherland-Hodgman algorithm, an old favorite that should be covered in any basic graphics textbook.

According to Vatti (q.v.) "This [algorithm] produces degenerate edges in certain concave / self intersecting polygons that need to be removed as a special extension to the main algorithm" (though this is not a problem if all you are doing with the results is scan converting them.)

It should be noted that the Sutherland-Hodgman algorithm may be used to clip a polygon against any convex polygon. Cf. also Subject 5.04.

  • [Foley, van Dam]: Section 3.14.1 (pp 124 - 126)
  • [Hearn]: Section 6-8, pp 237 - 242 (with actual C code!)

See also

http://www.csclub.uwaterloo.ca/u/mpslager/articles/sutherland/wr.html
Personal tools