---
title: "Weiler-Atherton polygon clipping"
subject: "Computer Graphics"
chapter: 3
key: "semester_5/computer_graphics:weiler-atherton-polygon-clipping"
source: https://www.bctengineer.com/q/semester_5/computer_graphics/weiler-atherton-polygon-clipping
site: BCT Engineering
---

# Weiler-Atherton polygon clipping

Computer Graphics · Chapter 3: Two –Dimensional Transformations

- Asked in: 2082 Kartik (new course), 5 marks
- Video: [Weiler-Atherton Polygon Clipping Algorithm](https://www.youtube.com/watch?v=LCMyWFxeuro) — Anmol Unpacks | Hidden Stories
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_graphics/weiler-atherton-polygon-clipping
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_graphics/chapter-3

## Question

Explain Weiler Atherton polygon clipping algorithm with an example.

## Short answer

Weiler–Atherton algorithm clips any polygon (convex or concave) against any window. It finds all intersections, marks entering/leaving; then traces the subject polygon inside the window, switching to the window boundary at leaving intersections. This yields correct output polygons. Example: triangle with vertices (5,5),(3,14),(14,3) clipped against square (0,0)–(10,10) produces polygon (7,10),(10,7),(10,3.89),(5,5),(3.89,10).

## Answer

The **Weiler-Atherton algorithm** clips any polygon (convex or concave) against any polygon window, and gives the correct output even when the result is several separate polygons. It works by following the boundary of the subject polygon and switching to the window boundary at the intersection points.

#### Terms
- **Entering intersection:** the subject polygon edge goes from outside to inside the window.
- **Leaving intersection:** the edge goes from inside to outside.

#### Algorithm (subject polygon vertices in clockwise order)
```text
1. Find all intersection points of the subject polygon with the window,
   and mark each as entering or leaving. Insert them into both vertex lists.
2. Start at an unvisited entering intersection.
3. Follow the subject polygon edges (inside the window), adding each vertex
   to the output, until a leaving intersection is reached.
4. At the leaving intersection, turn and follow the window boundary
   (clockwise) until the next intersection with the subject polygon.
5. Continue from that intersection along the subject polygon (step 3).
6. When back at the start point, close the output polygon.
7. Repeat from step 2 for any entering intersection not yet processed.
```

#### Example
Window: square (0,0)-(10,10). Subject triangle with vertices in clockwise order A(5,5), C(3,14), B(14,3).

```text
 y
14 C
   .
10 ---L1-----E1-----+  (10,10)
   |   .        .   |
   |      A       . |
 7 |                L2
   |                |
3.9|              E2--- B(14,3)
 0 +----------------+---- x
   0               10
```

Intersections: A→C leaves the window at L1 (3.89, 10); C→B enters at E1 (7, 10) and leaves at L2 (10, 7); B→A enters at E2 (10, 3.89).

1. Start at the entering point E1(7,10). Follow the subject edge C→B inside the window to the leaving point L2(10,7).
2. At L2, turn onto the window boundary and go clockwise (down the right edge) to the next intersection, E2(10,3.89).
3. At E2, return to the subject polygon: E2 → A(5,5) → leaving point L1(3.89,10).
4. At L1, follow the window boundary clockwise (along the top edge) to E1, the start point, and close the polygon.

**Output polygon:** (7,10), (10,7), (10,3.89), (5,5), (3.89,10).

**Advantages:** it handles concave polygons and correctly produces multiple output polygons (Sutherland-Hodgman can instead show extra connecting edges for concave polygons). **Disadvantage:** it is more complex to implement than Sutherland-Hodgman.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What makes Weiler-Atherton better than Sutherland-Hodgman?
   A. It is simpler to implement
   B. It handles concave polygons and can output several polygons
   C. It works only for convex polygons
   D. It only clips lines
   Answer: B. It correctly clips concave subject polygons and gives multiple separate polygons. (Key point: Capability)

2. What is an entering intersection?
   A. The edge goes from inside to outside
   B. Any polygon vertex
   C. The subject edge goes from outside to inside the window
   D. An intersection of two window edges
   Answer: C. Entering means outside to inside. (Key point: Intersection types)

3. At a leaving intersection, what do you do?
   A. Stop the algorithm
   B. Continue along the subject polygon
   C. Discard the polygon
   D. Turn and follow the window boundary clockwise to the next intersection
   Answer: D. At leaving points the traversal switches to the window boundary. (Key point: Traversal)

4. Where does the algorithm begin?
   A. At an unvisited entering intersection
   B. At the first window corner
   C. At the center of the polygon
   D. At a leaving intersection
   Answer: A. Start at an entering point and repeat for any unprocessed ones. (Key point: Starting point)

## Related in Computer Graphics

- [Cohen-Sutherland line clipping](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Acohen-sutherland-explain) — Computer Graphics, chapter 3, asked 2×
- [Point clipping and Cohen-Sutherland (5,130)-(50,5)](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Acohen-sutherland-point-clip-5-130) — Computer Graphics, chapter 3
