Clipping Any Procedure that identifies those portions of a picture that are either inside or outside of a specified region of a space is referred to as a Clipping algorithm or simply Clipping . The region against which an object is to clipped is called a Clip Window.
Clipping * Clipping algorithms are 2D-3D. * Clipping algorithm can be implemented in hardware or software. * When implemented in software, clipping algorithms are slower than required for real time applications. * For this reason both 2D & 3D clipping algorithm have been implemented in hardware or firmware. * The purpose of a clipping algorithm is to determine which points, lines or portions of lines lie with in the clipping window. * These points, lines or portions of lines are relative for display. * All other are discarded.
* Application of clipping include extracting part of a defined scene for viewing. * Identifying visible surface in 3D views. * Antiliasing line segment or object boundaries. * Creating objects using solid-modeling procedures. * Displaying a multi window environment. * Drawing & painting operation that allow part of a picture to be selected for clipping, moving, erasing or duplicating.
* Depending on the application, the clip window can be a general polygon or it can even have curved boundaries. * For the viewing transformation, we want to display only those picture parts that are within the window area. Everything outside the window is discarded. * Clipping algorithm can be applied in World Coordinates, so that only the contents of the window interior are mapped to Device coordinates.
* A line clipping procedure involves several parts.
* In many cases the large majority of points or lines are either interior or exterior to the clipping window.
* Therefore it is important to be able to quickly accept a line which is completely interior to the window & reject a line which is exterior to the window.
Line Clipping * Lines are interior to the clipping window & hence visible if both end points are interior to the window. * Points are interior to the clipping window provided that XL <= X <= XR YB <= Y <= YT
I J G H E F A B C D K L Right Bottom Top Left Line Clipping
Line Clipping * However, if both endpoints of a line are exterior to the window, the line is not necessarily completely exterior to the window. * If both end points of a lines are:-
# completely to the right of the window. # completely to the left of the window. # completely above the window. # completely bottom the window.
Then the line is completely exterior to the window & hence invisible
The tests for totally visible lines and the region tests for totally invisible lines can be formalized using a technique i.e. Cohen & Sutherland Algorithm.
The technique uses a four digit (bit) code, known as “Region Code”, to indicate which of nine regions contains the end points of a line.
Cohen & Sutherland Algorithm The rightmost bit is the first bit. The bits are set to 1 based on the following scheme. 1) First bit Set- If the end point is to the left of the window. 2) Second bit Set- If the end point is to the right of the window. 3) Third bit Set- If the end point is to the below the window. 4) Fourth bit Set- If the end point is to the above the window. Otherwise the bit is set to Zero. It is obvious that, if both end point codes are zero, then both ends of the line lie inside the window & the line is visible.