| written 6.4 years ago by |
A set of connected lines are considered as polygon; polygons are clipped based on the window and the portion which is inside the window is kept as it is and the outside portions are clipped. The polygon clipping is required to deal different cases. Usually it clips the four edges in the boundary of the clip rectangle.


Sutherland-Hodgeman Polygon Clipping Algorithm:
Read coordinates of all vertices of the Polygon.
Read coordinates of the dipping window
Consider the left edge of the window
Compare the vertices of each edge of the polygon, individually with the clipping plane.
Save the resulting intersections and vertices in the new list of vertices according to four possible relationships between the edge and the clipping boundary.
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.
Stop.
Example: For a polygon and clipping window shown in figure below give the list of vertices after each boundary clipping.

Solution: Original polygon vertices are $V_1, V_2, V_3, V_4$, and $V_5$. After clipping each boundary the new vertices are as shown in figure above.
After Left Clipping : $V_1, V'_1,V'_2,V_3,V_4,V_5$
After Left Clipping : $V_1, V'_1,V'_2,V_3,V_4,V_5$
After Left Clipping : $V_1, V'_1,V'_2,V_3,V'_3,V'_4,V_5$
After Left Clipping : $V^{\prime \prime}_2,V'_2,V_3,V'_3,V'_4,V_5,V'_5$

and 2 others joined a min ago.