Sutherland-Hodgeman Polygon clipping



Polygon:It is a closed shape of line segments.

Polygon clipping:For polygon clipping  we need to modify the line clipping procedures because in line clipping we only consider the line segment whereas in polygon clipping we need to consider the new boundary and the area of the polygon.
In polygon clipping we need to test whether the polygon is within the display window. And after that we need to clip the edged outside the display window.

Polygon clipping is of two types:

  • Concave polygon
  • Convex polygon
Sutherland-Hodgeman polygon clipping:It is performed by processing the boundary of the poygon against each window corner or edge.First of all the entire polygon is clipped against one window edge, then the resulting polygon is clipped against the next window edge, so on for all the four window edges.
First the polygon is clipped against the left edge of the clipping window to get new vertices of the polygon. These new vertices are used to clip the polygon against the right edge, bottom edge  and top edge of the clipping window as shown in the figure.


The initial image of the polygon before clipping against the clipping window




















There are four possible cases when processing vertices in sequence around the perimeter of a polygon.

  • As shown in case 1:if both vertices are inside the window we add only second vertices to output list.
  • in case 2: if first vertex is inside boundary and the second vertex is outside the boundary  only the edge intersection with the window boundary is added tot the vertex list.
  • in case 3:If both vertex are outside the window boundary nothing is added to window boundary.
  • in case 4: first vertex is outside and the second vertex is inside the boundary, then add both intersection point with  window boundary and second vertex to the output list.
convex polygons are correctly clipped using Sutherland-hodegeman algorithm but concave may be displayed with extra lines.

To overcome this problem we have one possible solution , it is to divide the polygon in to number od small convex polyon and then process them one by one.

Another approach is to use Weiler-Atherton algorithm.






Sutherland-Hodgeman Polygon Clipping Algorithm:-
  1. Read coordinates of all vertices of the Polygon.
  2. Read coordinates of the clipping window
  3. Consider the left edge of the window
  4. Compare the vertices of each edge of the polygon, individually with the clipping plane.
  5. Save the resulting intersections and vertices in the new list of vertices according to four possible relationships between the edge and the clipping boundary.
  6. Repeat the steps 4 and 5 for remaining edges or the clipping window. Each time the resultant list of vertices is successively passed to process the next edge of the clipping window.
  7. Stop



Disadvantages:
  • The sutherland- Hodgemon clipping procedure  always produces a single polygon output, even when the expected output is multiple concave polygon.


Comments