Weiler-Atherton Polygon Clipping
For polygon clipping, we need to modify the line clipping procedure because in line clipping we need to consider about only line segment while in polygon clipping we need to consider the area and the new boundary of the polygon after clipping.
In this algorithm vertex processing procedure for a window, the boundary is modified so that concave polygon also clips correctly.
This can apply for arbitrary polygon clipping regions as it developed for visible surface identification.
The main idea of this algorithm instead of always proceeding around the polygon edges as vertices processed we sometimes need to follow the window boundaries.
Another procedure similar to the Sutherland-Hodgeman algorithm.
For clockwise processing of polygon vertices we use the following Weiler-Atherton rules:
- Moreover, For an outside to inside pair of vertices, follow the polygon boundary.
- For an inside to outside pair of vertices, follow the window boundary in a clockwise direction.
We illustrate it with the Weiler-Atherton example:
As shown in the figure we start from v1 and move clockwise towards v2 and add intersection point and next point to output list by following polygon boundary, then from v2 to v3 we add v3 to the output list.
From v3 to v4 we calculate intersection point and add to output list and follow window boundary.
Similarly, from v4 to v5 we add intersection point and next point and follow the polygon boundary, next we move v5 to v6 and add intersection point and follow the window boundary, and finally v6 to v1 outside so no need to add anything.
This way we get two separate polygon section after clipping.