Sutherland-Hodgeman polygon clipping algorithm :-
- Read coordinates of all vertices of the polygon.
- Read coordinates of the clipping 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 cases between the edge and the clipping
boundary.
- Repeat the step 4 and 5 for remaining edges of the clipping window.
Each time the resultant list of vertices is successively passed, move the
process to the next edge of the clipping window.
- Stop.
Weiler-Atherton polygon clipping :-
- In this algorithm, the vertex processing procedure is modified so that
the concave polygons are displayed correctly.
- This algorithm depends on identifying surfaces as shown in Fig. 2.24.1.
- There are two directions (clockwise or anticlockwise) that exist to process
the polygon vertices.
For clockwise processing of polygon vertices, we use the following rules :
a. For an outside to inside pair of vertices, follow the polygon boundary.
b. For an inside to outside pair of vertices, follow the window boundary
in a clockwise direction.