Clipping
Procedure that identifies those portions of a
  picture that are either inside or outside a
  specified region of space is referred to as a
  clipping algorithm, or clipping. A region
  against which a object is to clipped is called
  a clip window. Application of clipping
  includes extracting a portion of a scene,
  drawing and painting operations.
In clipping only those elements will be
  displayed which comes inside the window.
Everything outside the window is discarded.
Sheilding: Determines those elements of the
          picture which will not be displayed.
Clipping is basically of following types:-
1.) Point Clipping
2.) Line Clipping
3.) Polygon Clipping
4.) Curve Clipping
5.) Text Clipping
Point Clipping
Assuming that the clip window is a rectangle
in standard position, we save a point P = (x,y)
for display if the following inequalities are
satisfied:           xwmin < x < xwmax
                    ywmin < y < ywmax
where the edges of the clip window(xwmin,
xwmax, xymin, xymax) can be either the world-
coordinate window boundaries or viewport
boundaries.
If any one of these four inequalities is not
satisfied, the point is clipped( not saved for
display).
Point clipping can be applied to scenes
   involving explosions or sea foam that are
   modeled with particles (points) distributed
   in some region of the scene.
Line Clipping
A Clipping line procedure involves two parts:
1.)If we cannot identify a line as completely
   inside or outside the clipping window then
   we must perform calculation of those lines
   which intersect the clipping window.
2.) Then we start clipping.
We process lines by checking their endpoints
& test which points of the lines comes inside
or outside the clip window.
P6              P2
                                        P8
          P1    P4
P5

P3
     Before Clipping      P7          Clipping Window

                     P2

          P1    P4
                                P8’
        P3’               P7’
      After Clipping
In Line Clipping some lines may be invisible
   some may be visible & some may be
   partially visible.
Line P1P2 is visible b’coz both endpoints
   comes inside the clipping window.
Line P5P6 is invisible b’coz there endpoints
   are completely exterior to the window.
Line P3P4 & P7P8 are partially visible lines.
COHEN- SUTHERLAND ALGORITHM
Steps for finding out the clipping of lines are:
1.) We use 4-bit code for every endpoint of
   the line. Bits are set to 1 depending upon
   the following conditions:
   1st bit (left most bit)- will set to 1 if end
   point is above the top edge of window.
   2nd bit – set to 1 if endpoint is below the
   bottom edge of the window.
   3rd bit – set to 1 if endpoint is to the right
   of the right edge of the window.
4th bit – set to 1 if endpoint is to the left of
the left edge of the window.
Left Edge                           Top Edge
    1001          1000              1010



                Clip Window         0010
  0001
                    0000


  0101              0100             0110
                                      Right Edge
Bottom Edge
P6             P2    P8
           P1
                P4
P5
     P3               P7
2.) Using coding scheme we can say that:
Line EP1 EP2 Logical             Results
                     AND
P1P2 0000 0000        0000 Totally visible
P3P4 0001 0000        0000 Partially visible
P5P6 0001 0001        0001 Totally invisible
P7P8 0000 0000        0000 Totally visible

3.) After selecting those lines which are
   partially visible, we determine those points
of the line which intersect with the Clipping
window boundaries. Then we subdivide the
intersection points into various smaller line
segments in visible & not visible categories.
The line segment which comes under visible
category will be clipped.
4.) Using the bit values of the endpoints of
intersecting lines we choose those endpoints
of segments which have no intersecting
Bit value (any bit value should not be 1) i.e
which have bit values equivalent to the
boundary of Clipping window(0000).
MIDPOINT SUBDIVISION ALGORIT:-
For Clipping any Partially visible line we use
this algorithm. It is based on the bisection
method.The line is divided at its midpoint into
two shorter line segments using the endpoint
values.
The midpoint coordinates (xm, ym) of aline
  joining (x1,y1) & (x2,y2) are given by
    xm = x1 + x2      ym = y1 + y2
            2                   2

Clipping

  • 1.
    Clipping Procedure that identifiesthose portions of a picture that are either inside or outside a specified region of space is referred to as a clipping algorithm, or clipping. A region against which a object is to clipped is called a clip window. Application of clipping includes extracting a portion of a scene, drawing and painting operations. In clipping only those elements will be displayed which comes inside the window.
  • 2.
    Everything outside thewindow is discarded. Sheilding: Determines those elements of the picture which will not be displayed. Clipping is basically of following types:- 1.) Point Clipping 2.) Line Clipping 3.) Polygon Clipping 4.) Curve Clipping 5.) Text Clipping
  • 3.
    Point Clipping Assuming thatthe clip window is a rectangle in standard position, we save a point P = (x,y) for display if the following inequalities are satisfied: xwmin < x < xwmax ywmin < y < ywmax where the edges of the clip window(xwmin, xwmax, xymin, xymax) can be either the world- coordinate window boundaries or viewport boundaries.
  • 4.
    If any oneof these four inequalities is not satisfied, the point is clipped( not saved for display). Point clipping can be applied to scenes involving explosions or sea foam that are modeled with particles (points) distributed in some region of the scene.
  • 5.
    Line Clipping A Clippingline procedure involves two parts: 1.)If we cannot identify a line as completely inside or outside the clipping window then we must perform calculation of those lines which intersect the clipping window. 2.) Then we start clipping. We process lines by checking their endpoints & test which points of the lines comes inside or outside the clip window.
  • 6.
    P6 P2 P8 P1 P4 P5 P3 Before Clipping P7 Clipping Window P2 P1 P4 P8’ P3’ P7’ After Clipping
  • 7.
    In Line Clippingsome lines may be invisible some may be visible & some may be partially visible. Line P1P2 is visible b’coz both endpoints comes inside the clipping window. Line P5P6 is invisible b’coz there endpoints are completely exterior to the window. Line P3P4 & P7P8 are partially visible lines.
  • 8.
    COHEN- SUTHERLAND ALGORITHM Stepsfor finding out the clipping of lines are: 1.) We use 4-bit code for every endpoint of the line. Bits are set to 1 depending upon the following conditions: 1st bit (left most bit)- will set to 1 if end point is above the top edge of window. 2nd bit – set to 1 if endpoint is below the bottom edge of the window. 3rd bit – set to 1 if endpoint is to the right of the right edge of the window.
  • 9.
    4th bit –set to 1 if endpoint is to the left of the left edge of the window. Left Edge Top Edge 1001 1000 1010 Clip Window 0010 0001 0000 0101 0100 0110 Right Edge Bottom Edge
  • 10.
    P6 P2 P8 P1 P4 P5 P3 P7
  • 11.
    2.) Using codingscheme we can say that: Line EP1 EP2 Logical Results AND P1P2 0000 0000 0000 Totally visible P3P4 0001 0000 0000 Partially visible P5P6 0001 0001 0001 Totally invisible P7P8 0000 0000 0000 Totally visible 3.) After selecting those lines which are partially visible, we determine those points
  • 12.
    of the linewhich intersect with the Clipping window boundaries. Then we subdivide the intersection points into various smaller line segments in visible & not visible categories. The line segment which comes under visible category will be clipped. 4.) Using the bit values of the endpoints of intersecting lines we choose those endpoints of segments which have no intersecting
  • 13.
    Bit value (anybit value should not be 1) i.e which have bit values equivalent to the boundary of Clipping window(0000). MIDPOINT SUBDIVISION ALGORIT:- For Clipping any Partially visible line we use this algorithm. It is based on the bisection method.The line is divided at its midpoint into two shorter line segments using the endpoint values.
  • 14.
    The midpoint coordinates(xm, ym) of aline joining (x1,y1) & (x2,y2) are given by xm = x1 + x2 ym = y1 + y2 2 2