Professional Documents
Culture Documents
Clipping polygons is more complex than clipping the individual lines Input: polygon Output: original polygon, new polygon, or nothing When can we trivially accept/reject a polygon as opposed to the line segments that make up the polygon?
triangle
triangle
triangle
quad
triangle
5-gon
Page 1
concave polygon
multiple polygons
Sutherland-Hodgeman Clipping
Basic idea: Consider each edge of the viewport individually Clip the polygon against the viewport edges equation
Sutherland-Hodgeman Clipping
Basic idea:
Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all edges, the polygon is fully clipped
Page 2
Sutherland-Hodgeman Clipping
Basic idea:
Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all edges, the polygon is fully clipped
Sutherland-Hodgeman Clipping
Basic idea:
Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all edges, the polygon is fully clipped
10
Sutherland-Hodgeman Clipping
Basic idea:
Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all edges, the polygon is fully clipped
Sutherland-Hodgeman Clipping
Basic idea:
Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all edges, the polygon is fully clipped
11
12
Page 3
Sutherland-Hodgeman Clipping
Basic idea:
Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all edges, the polygon is fully clipped
Sutherland-Hodgeman Clipping
Basic idea:
Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all edges, the polygon is fully clipped
13
14
Sutherland-Hodgeman Clipping
Basic idea:
Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all edges, the polygon is fully clipped
Sutherland-Hodgeman Clipping:
Basic idea:
Consider each edge of the viewport individually Clip the polygon against the edge equation After doing all edges, the polygon is fully clipped
15
16
Page 4
Sutherland-Hodgeman Clipping
Input/output for algorithm: Input: list of polygon vertices in order Output: list of clipped poygon vertices consisting of old vertices (maybe) and new vertices (maybe) Note: this is exactly what we expect from the clipping operation against each edge
Sutherland-Hodgeman Clipping
Sutherland-Hodgman basic routine: Go around polygon one vertex at a time Current vertex has position p Previous vertex had position s, and it has been added to the output if appropriate
17
18
Sutherland-Hodgeman Clipping
Edge from s to p takes one of four cases:
(Orange line can be a line or a plane)
outside inside outside
Sutherland-Hodgeman Clipping
3
inside
inside
outside
inside
outside
p s
2 4 1 6
p
p output
s
i output
p
no output
s
i output p output
19
20
Page 5
Sutherland-Hodgeman Clipping
3
Sutherland-Hodgeman Clipping
3 2` 2 1` 4 1 6
2 4 1 6 5
21
22
Sutherland-Hodgeman Clipping
3 2` 2 1 6 5` 4` 5 1` 3` 4
Sutherland-Hodgeman Clipping
2` 1` 3` 5` 4`
23
24
Page 6
25
26
27
28
Page 7
29
30
31
32
Page 8
Weiler Atherton
33
34
Weiler Atherton
35
Page 9