Clipping Polygons Dr Scott Schaefer 1 Clipping Polygons

  • Slides: 113
Download presentation
Clipping Polygons Dr. Scott Schaefer 1

Clipping Polygons Dr. Scott Schaefer 1

Clipping Polygons 2/86

Clipping Polygons 2/86

Clipping Polygons 3/86

Clipping Polygons 3/86

Why Is Polygon Clipping Hard? n What happens to a triangle during clipping? -

Why Is Polygon Clipping Hard? n What happens to a triangle during clipping? - possible outcomes: triangle quad triangle 5 -gon 4/86

Why Is Polygon Clipping Hard? n What happens to a triangle during clipping? -

Why Is Polygon Clipping Hard? n What happens to a triangle during clipping? - possible outcomes: triangle quad triangle 5 -gon How many sides could a clipped triangle have? 5/86

How Many Sides? 7 6/86

How Many Sides? 7 6/86

Why Is Polygon Clipping Hard? Concave polygon Multiple polygons 7/86

Why Is Polygon Clipping Hard? Concave polygon Multiple polygons 7/86

Why Is Polygon Clipping Hard? n A really tough case 8/86

Why Is Polygon Clipping Hard? n A really tough case 8/86

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation 9/86

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation 10/86

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation 11/86

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation 12/86

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation 13/86

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation 14/86

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation 15/86

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation 16/86

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation 17/86

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually

Sutherland-Hodgman Clipping n Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation - after doing all edges, the polygon is fully clipped 18/86

Sutherland-Hodgman Clipping n Input/output for algorithm: - input: list of polygon vertices in order

Sutherland-Hodgman Clipping n Input/output for algorithm: - input: list of polygon vertices in order {abcdef} a b f e d c 19/86

Sutherland-Hodgman Clipping n Input/output for algorithm: - input: list of polygon vertices in order

Sutherland-Hodgman Clipping n Input/output for algorithm: - input: list of polygon vertices in order - output: list of clipped polygon vertices consisting of old vertices (maybe) and new vertices (maybe) 20/86

Sutherland-Hodgman Clipping n Edge from S to E takes one of four cases: outside

Sutherland-Hodgman Clipping n Edge from S to E takes one of four cases: outside inside outside E S E no output inside E output inside outside inside S E S I output E output 21/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 22/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 23/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 24/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 25/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 26/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 27/86

Sutherland-Hodgman Algorithm Out In No output b Out In Output E Out In Output

Sutherland-Hodgman Algorithm Out In No output b Out In Output E Out In Output I, E 28/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 29/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 30/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 31/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 32/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 33/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 34/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 35/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 36/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 37/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 38/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 39/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 40/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 41/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 42/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 43/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 44/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 45/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 46/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 47/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 48/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 49/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 50/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 51/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 52/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 53/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 54/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 55/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 56/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 57/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 58/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 59/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 60/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 61/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 62/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 63/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 64/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E Possible error for nonconvex polygons 65/86

Sutherland-Hodgman Algorithm Easy to pipeline for parallel processing n Polygon from one boundary does

Sutherland-Hodgman Algorithm Easy to pipeline for parallel processing n Polygon from one boundary does not have to be complete before next boundary starts n n Leads to substantial performance gains 66/86

Weiler-Atherton Algorithm General polygon vs. polygon clipping n Handles non-convex shapes n Not as

Weiler-Atherton Algorithm General polygon vs. polygon clipping n Handles non-convex shapes n Not as efficient as Sutherland-Hodgman n Not easy to parallelize n 67/86

Weiler-Atherton Algorithm n n Process the edges of the polygon in a counterclockwise order

Weiler-Atherton Algorithm n n Process the edges of the polygon in a counterclockwise order until an inside-outside pair of vertices is encountered Follow the window boundaries in a counterclockwise direction from the exitintersection point to another intersection point with the polygon Repeat until at a previously processed vertex Return to the exit-intersection point and continue processing the polygon edges in a counterclockwise order 68/86

Weiler-Atherton Algorithm 69/86

Weiler-Atherton Algorithm 69/86

Weiler-Atherton Algorithm 70/86

Weiler-Atherton Algorithm 70/86

Weiler-Atherton Algorithm 71/86

Weiler-Atherton Algorithm 71/86

Weiler-Atherton Algorithm 72/86

Weiler-Atherton Algorithm 72/86

Weiler-Atherton Algorithm 73/86

Weiler-Atherton Algorithm 73/86

Weiler-Atherton Algorithm 74/86

Weiler-Atherton Algorithm 74/86

Weiler-Atherton Algorithm 75/86

Weiler-Atherton Algorithm 75/86

Weiler-Atherton Algorithm 76/86

Weiler-Atherton Algorithm 76/86

Weiler-Atherton Algorithm 77/86

Weiler-Atherton Algorithm 77/86

Weiler-Atherton Algorithm 78/86

Weiler-Atherton Algorithm 78/86

Weiler-Atherton Algorithm 79/86

Weiler-Atherton Algorithm 79/86

Weiler-Atherton Algorithm 80/86

Weiler-Atherton Algorithm 80/86

Weiler-Atherton Algorithm 81/86

Weiler-Atherton Algorithm 81/86

Weiler-Atherton Algorithm 82/86

Weiler-Atherton Algorithm 82/86

Weiler-Atherton Algorithm 83/86

Weiler-Atherton Algorithm 83/86

Weiler-Atherton Algorithm 84/86

Weiler-Atherton Algorithm 84/86

Weiler-Atherton Algorithm 85/86

Weiler-Atherton Algorithm 85/86

Weiler-Atherton Algorithm 86/86

Weiler-Atherton Algorithm 86/86

87/86

87/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 88/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 89/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 90/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 91/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 92/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 93/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 94/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 95/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 96/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 97/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 98/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 99/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 100/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 101/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 102/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 103/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 104/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 105/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 106/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 107/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 108/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 109/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 110/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 111/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 112/86

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I,

Sutherland-Hodgman Algorithm Out In No output Out In Output E Out In Output I, E 113/86