5 Clipping Algorithms

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.

Clipping Algorithms: notes

Line clipping concepts and role

Clipping is the process of finding which part of an object lies inside a given region, called the clipping window, and discarding the rest.

Role of clipping:

  • Removes parts of the picture that are outside the view, so they are not processed further.
  • Saves time and memory, since fewer pixels need to be drawn.
  • Prevents drawing outside the screen or window, which may corrupt other data.
  • Lets us show a chosen part of a large scene, as in zoom.
  • Helps in 3D by removing parts behind the camera before projection.

For a line, there are three possible cases against a rectangular window:

  • Both endpoints inside: accept the whole line.
  • Both endpoints outside on the same side: reject the whole line.
  • Otherwise the line is partly inside, so we find the intersection with the window edges and keep the inside part.

Cohen-Sutherland line clipping algorithm

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]

Polygon vertices (in order): - A(3, 4) - B(7, 4) - C(7, 8) - D(3, 8) Clipping window (rectangle): - Lower-left corner: (4, 5) - Upper-right corner: (6, 7) Derived window edges: - Left: $x{min} = 4$ - Right: $x{max} = 6$ - Bottom: $y{min} = 5$ - Top: $y{max} = 7$ Note: The original polygon ABCD is...

Open this answer on its own page →

2080 · 10 marks

How Can Polygons Be Clipped? Describe Gouraud Shading Model with Necessary Derivations [10]

Definition: Polygon clipping is the process of removing portions of a polygon that lie outside a specified clipping window while retaining and correctly connecting the portions inside. The most common polygon clipping method processes the polygon against each edge of the clipping window sequentia...

Open this answer on its own page →

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 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:

  1. Visibility determination: It decides which parts of an object are visible within the viewing window and which parts must be removed.

  2. Computational efficiency: By eliminating objects or portions of objects lying outside the display region, less data is passed to the rendering pipeline, improving speed.

  3. Preventing overflow/artifacts: It stops drawing outside valid display boundaries, avoiding wrap-around, garbage pixels, and memory errors.

  4. Zooming and panning support: Correct clipping is essential when a scene is scaled or scrolled so only the relevant window contents appear.

  5. 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.

Stepx (exact)y (exact)Plotted (round)
020.010.0(20, 10)
121.010.8(21, 11)
222.011.6(22, 12)
323.012.4(23, 12)
424.013.2(24, 13)
525.014.0(25, 14)
626.014.8(26, 15)
727.015.6(27, 16)
828.016.4(28, 16)
929.017.2(29, 17)
1030.018.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)$.

Open this answer on its own page →

Cohen-Sutherland line clipping algorithm

2080 · 5 marks

Explain Cohen-Sutherland Line Clipping algorithm with example. [5]

The Cohen-Sutherland algorithm is a line clipping algorithm used to determine which portions of a line lie within a rectangular clipping window and should be displayed. It uses a region coding scheme to efficiently identify and clip lines. Divide the plane into 9 regions using a rectangular clipp...

Open this answer on its own page →

2079 · 5 marks

Explain Cohen-Sutherland line clipping Algorithm. [5]

The Cohen-Sutherland algorithm is a line clipping algorithm used to determine which portions of a line lie within a rectangular clipping window and should be displayed. It efficiently clips lines by dividing the plane into regions and using binary codes to classify endpoints. The plane is divided...

Open this answer on its own page →