Lecture6
Lecture6
Clipping
Associate Professor
Dr. Ashraf Abdelaziz Taha
The only part of the scene that shows up on the screen is what is inside
the clipping window.
Objects inside the clipping window are mapped to the viewport
-2-
A clipping window and associated viewport, specified as
rectangles aligned with the coordinate axes.
-3-
Mapping the Clipping Window into a Viewport
-4-
Clipping Algorithms
• Point clipping
• Line clipping (straight-line segments)
• Fill-area clipping (polygons)
-5-
Two-Dimensional Point Clipping
P = (x, y)
xmin ≤ x ≤ xmax
ymin ≤ y ≤ ymax
-6-
Two-Dimensional Line Clipping
First, determine whether a line segment is completely inside the clipping window
or completely outside.
Perform intersection calculations to determine whether any part of the line
crosses the window interior.
-7-
• When both endpoints of a line segment are inside all four clipping
boundaries, such as the line from P1 to P2, the line is completely
inside the clipping window.
• When both endpoints of a line segment are outside any one of the
four boundaries, such as the line P3 to P4, the line is completely
outside the window.
-8-
Cohen-Sutherland Line Clipping
Thus, an endpoint that is below and to the left of the clipping window is assigned the
region code 0101, and the region-code value for any endpoint inside the clipping
window is 0000. -9-
-10-
Polygon Fill-Area Clipping
-11-
Processing a polygon fill area against successive clipping-window boundaries.
-12-