1 / 124

CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai

CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai. Reminder. Homework #2 is due by Friday night Homework #3 will be posted on Friday night (2/8), due by 2/22. Review: Clipping Points.

charlesmera
Download Presentation

CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCE 441 Computer Graphics:Clipping PolygonsJinxiang Chai

  2. Reminder • Homework #2 is due by Friday night • Homework #3 will be posted on Friday night (2/8), due by 2/22

  3. Review: Clipping Points • Given a point (x, y) and clipping window (xmin, ymin), (xmax, ymax), determine if the point should be drawn (xmax,ymax) (x,y) xmin=<x<=xmax? (xmin,ymin) ymin=<y<=ymax?

  4. Review: Clipping Lines

  5. Review: Clipping Lines

  6. Review Clipping • Simple line clipping algorithm - compute intersection points - clip the line segment between the outside point and intersection point • Cohen-Sutherland - region coding (9 regions, 4bits) - best used when trivial acceptance and rejection is possible for most lines • Liang-Barsky - computation of t-intersections is cheap (only one division) - computation of (x,y) clip points is only done once - algorithm doesn’t consider trivial accepts/rejects - best when many lines must be clipped

  7. Clipping Polygons • Clipping polygons is more complex than clipping the individual lines • - Input: polygon

  8. Clipping Polygons • Clipping polygons is more complex than clipping the individual lines • - Input: polygon • - Output: original polygon, new polygon, or nothing

  9. Why Is Polygon Clipping Hard? • What happens to a triangle during clipping? - possible outcomes: triangle->triangle triangle->quad triangle->5-gon

  10. Why Is Polygon Clipping Hard? What happens to a triangle during clipping? - possible outcomes: triangle->triangle triangle->quad triangle->5-gon How many sides a clipped triangle might have? 10

  11. How Many Sides? • Seven

  12. Why Is Clipping Hard? • A really tough case Concave polygon -> Multiple polygons

  13. Why Is Clipping Hard? • A really tough case

  14. Outline • Sutherland-Hodgman Clipping - convex polygons • Weiler-Atherton Algorithm - general polygons • Required readings - HB 8-8

  15. Any idea? Clipping polygon edges? 15

  16. Any idea? • Clipping polygon edges?

  17. Any idea? Clipping polygon edges? 17

  18. Any idea? Clipping polygon edges? 18

  19. Any idea? • Clipping polygon edges? Unconnected set of lines!

  20. Any idea? Clipping polygon edges? Wrong even with connected line segments! 20

  21. Sutherland-Hodgman Clipping • Basic idea: similar to line clipping

  22. Sutherland-Hodgman Clipping Basic idea: similar to line clipping - consider each edge of the view window individually - clip the polygon against the view window edge’s equation 22

  23. Sutherland-Hodgman Clipping • Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation

  24. Sutherland-Hodgman Clipping • Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation

  25. Sutherland-Hodgman Clipping • Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation

  26. Sutherland-Hodgman Clipping • Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation

  27. Sutherland-Hodgman Clipping • Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation

  28. Sutherland-Hodgman Clipping • Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation

  29. Sutherland-Hodgman Clipping • Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation

  30. Sutherland-Hodgman Clipping • Basic idea: - consider each edge of the view window individually - clip the polygon against the view window edge’s equation

  31. Sutherland-Hodgman Clipping • 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

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

  33. Sutherland-Hodgman Clipping • 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)

  34. Sutherland-Hodgman Clipping • 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) - exactly what expect from the clipping operation against each edge!

  35. Sutherland-Hodgman Clipping • Basic routine: - Go around polygon one vertex at a time - Current vertex has position E - Previous vertex had position S, and it has been added to the output if appropriate a f b e d {abcdef} c

  36. Sutherland-Hodgman Clipping • Basic routine: - Go around polygon one vertex (i.e. polygon edge) at a time - Current vertex has position E - Previous vertex had position S, and it has been added to the output if appropriate a f b e d {abcdef} c

  37. Sutherland-Hodgman Clipping Basic routine: - Go around polygon one vertex (i.e. polygon edge) at a time - Current vertex has position E - Previous vertex had position S, and it has been added to the output if appropriate a f b e d {abcdef} c Need to determine output vertices for each polygon line! 37

  38. Sutherland-Hodgman Clipping • Polygon edge from S to E takes one of four cases: inside outside inside outside inside outside inside outside E S E S E S E S

  39. Sutherland-Hodgman Clipping Polygon edge from S to E takes one of four cases: inside outside inside outside inside outside inside outside E S E S E S E S I outputE output E output I output no output 39

  40. Sutherland-Hodgman Clipping • Four cases: • S inside plane and E inside plane • Add E to output • Note: S has already been added • S inside plane and E outside plane • Find intersection point I • Add I to output • S outside plane and E outside plane • Add nothing • S outside plane and E inside plane • Find intersection point I • Add I to output, followed by E

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

  42. Out In Out In Out In Out In Output I,E No output Output E Output I Sutherland-Hodgman Algorithm Input vertices after clipping against left edge after clipping against right edge after clipping against bottom edge after clipping all the window edges

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

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

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

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

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

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

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

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

More Related