You are on page 1of 12

Polygon Clipping

Sutherland-Hodgman’s Polygon Clipping


• Uses a divide-and-conquer strategy.

• Clip a polygon against a single infinite clip edge.

• Four clip edges, each defining one boundary of the


clip rectangle, successively clip a polygon against a
clip rectangle.

• Polygons can be clipped against each edge of the


window one at a time.
Sutherland-Hodgman’s Polygon Clipping
Sutherland-Hodgman’s Polygon Clipping
• Case 1: Wholly inside visible region save endpoint

• Case 2: Exit visible region save the intersection


point

• Case 3: Wholly outside visible region-save nothing

• Case 4: Enter visible region-save intersection and


endpoint
Sutherland-Hodgman’s Polygon Clipping
Sutherland-Hodgman’s Polygon Clipping
Sutherland-Hodgman’s Polygon Clipping
Sutherland-Hodgman’s Concave polygons
Clipping
Weiler-Atherton Polygon Clipping
•  The algorithm can support holes
• For an inside-to-outside pair of vertices, follow
the window boundary in a clockwise direction
• Use parity method to check holes.
Weiler-Atherton Polygon
Clipping
• Example:

Follow clip edge until


Out -> In In -> Out
In -> In (a) new crossing found
Add clip vertex Add clip vertex
Add end vertex (b) reach vertex already
Add end vertex Cache old direction
added
Weiler-Atherton Polygon
Clipping
• Example (cont’d):

Continue from Follow clip edge until


Out -> In In -> Out
cached vertex and (a) new crossing found
Add clip vertex Add clip vertex
direction (b) reach vertex already
Add end vertex Cache old direction
added
Weiler-Atherton Polygon
Clipping
• Example (cont’d):

Final Result:
Continue from
Nothing added
2 unconnected
cached vertex and polygons
Finished
direction

You might also like