Computer Graphics · Unit 5
Clipping Algorithms
Exam-focused notes for Clipping Algorithms (Computer Graphics, BIT304): what the TU syllabus asks and how it has actually been tested, with 5 solved past questions from this unit.
Clipping Algorithms in short
Clipping removes the parts of a picture that lie outside the area we want to see. It saves time, because we draw only what can be seen, and it stops drawing outside the screen.
What this unit covers
- Line clipping concepts and role
- Cohen-Sutherland line clipping algorithm
- Polygon clipping techniques
- Sutherland-Hodgman polygon clipping algorithm
- Clipping window and viewport
Sutherland-Hodgman polygon clipping algorithm
2082 · 5 marks
Given a polygon with vertices $A(3, 4)$, $B(7, 4)$, $C(7, 8)$, $D(3, 8)$, clip it against a rectangular window with coordinates $(4, 5)$, $(6, 7)$ using Sutherland-Hodgman polygon clipping algorithm. [5]
2080 · 10 marks
How Can Polygons Be Clipped? Describe Gouraud Shading Model with Necessary Derivations [10]
Line clipping concepts and role
2081 · 10 marks
What is the role of clipping? Plot the line with end points (20, 10) and (30, 18) using DDA.[10]
Show solved answerHide answer
Model Answer: Clipping and DDA Line Drawing
Part 1: Role of Clipping
Clipping is the process of identifying and retaining only those portions of a picture (points, lines, polygons, text, curves) that lie inside a specified region called the clipping window (or viewport), while discarding the portions that fall outside it.
Roles / Importance of Clipping:
-
Visibility determination: It decides which parts of an object are visible within the viewing window and which parts must be removed.
-
Computational efficiency: By eliminating objects or portions of objects lying outside the display region, less data is passed to the rendering pipeline, improving speed.
-
Preventing overflow/artifacts: It stops drawing outside valid display boundaries, avoiding wrap-around, garbage pixels, and memory errors.
-
Zooming and panning support: Correct clipping is essential when a scene is scaled or scrolled so only the relevant window contents appear.
-
Applications: Extracting part of a scene for viewing, drawing operations (erase, copy, move), displaying multi-window environments, solid modeling, and anti-aliasing at edges.
Common clipping algorithms include Cohen-Sutherland and Liang-Barsky (line clipping) and Sutherland-Hodgman (polygon clipping).
Part 2: DDA Line Drawing
DDA (Digital Differential Analyzer) is an incremental scan-conversion line algorithm that computes successive pixel positions using floating-point increments.
Given Data
- $(x_0, y_0) = (20, 10)$
- $(x_1, y_1) = (30, 18)$
Step 1: Compute differences
$$\Delta x = x_1 - x_0 = 30 - 20 = 10$$ $$\Delta y = y_1 - y_0 = 18 - 10 = 8$$
Step 2: Determine number of steps
$$\text{steps} = \max(|\Delta x|, |\Delta y|) = \max(10, 8) = 10$$
Step 3: Compute increments
$$x_{inc} = \frac{\Delta x}{\text{steps}} = \frac{10}{10} = 1.0$$ $$y_{inc} = \frac{\Delta y}{\text{steps}} = \frac{8}{10} = 0.8$$
Step 4: Generate points
Starting at $(20, 10)$, add increments each step and round to nearest integer.
| Step | x (exact) | y (exact) | Plotted (round) |
|---|---|---|---|
| 0 | 20.0 | 10.0 | (20, 10) |
| 1 | 21.0 | 10.8 | (21, 11) |
| 2 | 22.0 | 11.6 | (22, 12) |
| 3 | 23.0 | 12.4 | (23, 12) |
| 4 | 24.0 | 13.2 | (24, 13) |
| 5 | 25.0 | 14.0 | (25, 14) |
| 6 | 26.0 | 14.8 | (26, 15) |
| 7 | 27.0 | 15.6 | (27, 16) |
| 8 | 28.0 | 16.4 | (28, 16) |
| 9 | 29.0 | 17.2 | (29, 17) |
| 10 | 30.0 | 18.0 | (30, 18) |
(Note: rounding uses standard round-half-up; e.g. 12.4 → 12, 15.6 → 16.)
Plot
y
18 | *
17 | *
16 | * *
15 | *
14 | *
13 | *
12 | * *
11 |*
10 *
+----+----+----+----+----+----+----+----+----+----+---> x
20 21 22 23 24 25 26 27 28 29 30
The plotted pixels approximate a straight line from $(20, 10)$ to $(30, 18)$.
Cohen-Sutherland line clipping algorithm
2080 · 5 marks
Explain Cohen-Sutherland Line Clipping algorithm with example. [5]
2079 · 5 marks
Explain Cohen-Sutherland line clipping Algorithm. [5]
Make Unit 5 stick
Practice BIT304 with flashcards & quizzes