- Back to Home »
- Computer Graphics »
- Sutherland-Hodgeman Polygon Clipping
In polygon clipping, we use an algorithm that generates one or more closed areas that are then scan converted for the appropriate area fill. The output of a polygon clipper should be a sequence of vertices that define the clipped polygon boundaries. We can correctly clip a polygon by processing the polygon boundary as whole each window edge.
This could be accomplished by processing all polygon vertices against each clip rectangle boundary in turn. Beginning with the initial set of polygon vertices, we could first clip the polygon against the left rectangle boundary to produce a new sequence of vertices. The new set of vertices could then be successively passed to a right boundary clipper and a top boundary clipper. There are four possible cases when processing vertices in sequence around the perimeter of a polygon.
As each pair of adjacent polygon vertices is passed to a window boundary clipper, we make the following tests:
1) if the first vertex is outside the window boundary and the second vertex is inside, both the intersection point of the polygon edge with the window boundary and the second vertex are added to the output vertex list.
2) If both input vertices are inside the window boundary, only the second vertex is added to the output vertex list.
3) If the first vertex is inside the window boundary and the second vertex is outside, only the edge intersection with the window boundary is added to the output vertex list.
4) If both input vertices are outside the window boundary, nothing is added to the output list.