2. 2D CLIPPING
Any procedure which identifies that portion of a
picture which is either inside or outside a region
is referred to as a clipping algorithm or
clipping.
The region against which an object is to be
clipped is called clipping window.
3. 2D Clipping
Point clipping easy: Just check the inequalities
xmin < x < xmax
ymin < y < ymax
Line clipping more tricky
4. Cohen Sutherland clipping Algorithm
The Cohen–Sutherland algorithm is a computer
graphics algorithm used for line clipping
5. Cohen Sutherland clipping Algorithm
Every line endpoint is assigned a 4 bit Region code. The
appropriate bit is set depending on the location of the endpoint
with respect to that window component as shown below:
Endpoint Left of window then set bit 1
Endpoint Right of window then set bit 2
Endpoint Below window then set bit 3
Endpoint Above window then set bit 4
6. Cohen-Sutherland Line Clipping
To clip a line, find out which regions its two endpoints lie in.
If they are both in region 0000, then it’s completely in.
If the two region numbers both have a 1 in the same bit
position, the line is completely out.
Otherwise, we have to do some more calculations.
7. Cohen-Sutherland clipping algorithm
To clip a line, find out which regions its two endpoints lie in.
If they are both in region 0000, then it’s completely in.
If the two region numbers both have a 1 in the same bit
position, the line is completely out.
Otherwise, we have to do some more calculations.
8. Cohen-Sutherland Clipping Algorithm
For those lines that we cannot immediately
determine, we successively clip against each
boundary.
Then check the new endpoint for its region
code.
How to find boundary intersection: To find
y coordinate at vertical
intersection, substitute x value at the
boundary into the line equation of the line
to be clipped.