Overlapping or Intersecting
A polygon overlaps or intersects the current background if any of its sides cuts the edges of the viewport as depicted at the top right corner of the viewport.
The extent of a polygon overlapping the viewport is only a necessary but not sufficient condition, because even if the extent overlaps, the polygon may be disjoint, as illustrated at the top left corner of the viewport. It may be seen that only the surrounding and contained cases (a) and (b) may be decided on the basis of the simple rules of relationship between the x-y extents of the polygon and the viewport. All other cases need further investigation, as follows :
We start with the entire viewport, and examine all the polygons for surrounding or containment. Whatever polygons can be classified as Case (a) or Case (b) can be stored or not depending on whether they are visible or not.
For any remaining polygons, the viewport is divided into four quarters, and each quarter representing a viewport segment is evaluated against the polygon portions in that quarter for cases (a) and (b). The quarter or quarters in which such determination cannot be made will again be subdivided into four further quarters each, and each quarter (which may be termed a "viewport segment") examined for the same kind of relationship decisions.
This procedure is applied with successive subdivisions until all the polygons and sub-regions can be resolved as (a) or (b). Frequently, the procedure may have to be repeated until the last quartering reduces to a single pixel. Because of the four branches formed with each quartering step, the method is also called the Quad tree method. Finally, the method illustrates the difference between hidden-line and hidden-surface algorithms. In a particular viewport segment, it may happen that there are no edges at all, but two or more surfaces are surrounding the viewport segment. Here, hidden line has no relevance, but hidden surface has.