Lecture 6
Clipping
Associate Professor
Dr. Ashraf Abdelaziz Taha
Course Title: Computer Graphics
Semester: 1 2024 / 2025
Duration: 12 weeks
Concept of Clipping
A section of a two-dimensional scene that is selected for display is
called a clipping window because all parts of the scene outside the
selected section are “clipped” off.
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
A point (xw, yw) in a world-coordinate clipping window is mapped to viewport
coordinates (xv, yv), so that the relative positions of the two points in their respective
rectangles are the same.
-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
A line-clipping algorithm applied to
the line segments of the polygon boundary in (a) Display of a correctly clipped polygon fill area.
generates the unconnected set of lines in (b).
-11-
Processing a polygon fill area against successive clipping-window boundaries.
-12-