1 / 27

Clipping Polygons

Clipping Polygons. Dr Nicolas Holzschuch University of Cape Town e-mail: holzschu@cs.uct.ac.za Modified by Longin Jan Latecki latecki@temple.edu Sep. 11, 2002. Map of the lecture. Problems in clipping polygons Clipping polygons against one edge of the window against the whole window

Download Presentation

Clipping Polygons

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. Clipping Polygons Dr Nicolas Holzschuch University of Cape Town e-mail: holzschu@cs.uct.ac.za Modified by Longin Jan Latecki latecki@temple.edu Sep. 11, 2002

  2. Map of the lecture • Problems in clipping polygons • Clipping polygons • against one edge of the window • against the whole window • Clipping other shapes • Accelerating the clipping

  3. Clipping a polygon • Different possible cases • We have to fill the result of clipping

  4. A polygon must be filled • We have to fill the result: • must indentify the new edges • the result must be closed Polygon being clipped Window Resulting polygon

  5. Several new polygons • Clipping a polygon may result in several new polygons: Polygon being clipped Window The data structure must provide for this Resulting polygons

  6. Clipping a polygon: algorithm • Start by clipping against a window boundary • Do each polygon edge in turn • Clip each polygon edge against the boundary: • If leaving, connect to latest entering • If entering, connect to latest leaving

  7. Polygon against boundary Outside

  8. Polygon against boundary Inside Outside

  9. Polygon against boundary

  10. Polygon against boundary

  11. Polygon against boundary

  12. Polygon against boundary

  13. Polygon against boundary

  14. Polygon against boundary

  15. Polygon against boundary Connect

  16. Polygon against boundary

  17. Polygon against window • Do each window boundary in turn • For each window boundary, clip the polygon using previous algorithm • The result is a closed polygon or several closed polygons • These are fed to the next window boundary

  18. Polygon against window First edge

  19. Polygon against window Second edge

  20. Polygon against window Third edge

  21. Polygon against window Fourth edge

  22. Clipping Polygons: conclusion • A more complex algorithm • Algorithmic complexity: 4 times the number of edges • Easy to implement using standard languages

  23. Other shapes (circles) • Convert the shape to polygon, then clip the polygon • problem: too many edges on the polygon • Clip the shape during rasterization • problem: rasterizing invisible parts • can be accelerated by eliminating parts that are trivially invisible

  24. Accelerating clipping • Clipping can be a costly step • Optimization: • use extents and don’t clip parts that are: • trivially invisible • trivially visible

  25. ymax ymin xmin xmax Extents • Compute the x-extent and the y-extent of the shape:

  26. Trivial accept/reject • Check the extent with the window: REJECT ACCEPT

  27. Trivial accept/reject • Spend some time doing a trivial test • Gain more time by avoiding complex computations • A common idea to many computer graphics algorithms

More Related