The objective of clipping is to determine which portion of a scene is visible within the window. For viewing transformation, only these portions are retained for display and everything outside the window are to be clipped.
Clipping algorithms are two or three dimensional and are for regular or irregular regions or volumes. Clipping algorithms can be implemented in hardware and software. When implemented in software, clipping algorithms often slower than required for real time applications. For this reason both 2D and 3D clipping algorithms have been implemented in hardware and firmware.
These implementations are usually confined to regular clipping regions.
Algorithms that we are considering for clipping:
Polygon and ellipse clipping
Assume that the clip window is rectangle in standard position. We have a point P(x, y) and it can be seen if the following two conditions are to be satisfied
xmax ≥ x ≥ xmin
ymax ≥ y ≥ ymin
Here two points P and P’ and a view area having the diagonal co-ordinate is shown. The point P will be visible and P’ will not be visible.
We can define the line clipping algorithm to set the portion of the line to be seen into the define viewport area. But due to the presence of two points (i.e., end points) it is different from point clipping. To decide whether the line can be viewed or not or whether some portion of the line can be viewed on the viewport, the following steps are followed:
If both the endpoints of a line are outside the viewing area, it can’t be displayed.
And if both the endpoints of a line are inside the viewing area, the complete line will be visible.
If some portions of the line or one or two endpoint is outside the viewing area, the portion of the line is to be displayed.
This can be illustrated by the following figure.
See the figure, there are four lines shown. The line AB can be viewed completely as both of its endpoint lies in the viewing area. Similarly, the line CD cannot be viewed at all as no part of the line lies within the viewing area. In the same way, the line EF and GH are partially seen in the viewing area as they intersect with the viewing boundary.