1 / 21

Clipping on a Raster Display

Clipping on a Raster Display. Approaches to Clipping. Analytical Clipping. Clipping Lines Against Rectangles. Clipping Rules. Computing Intersections. Cohen-Sutherland Algorithm. Outcodes. Outcode Computation. typedef unsigned int outcode;

pterry
Download Presentation

Clipping on a Raster Display

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 on a Raster Display 168 471 Computer Graphics, KKU. Lecture 8

  2. Approaches to Clipping 168 471 Computer Graphics, KKU. Lecture 8

  3. Analytical Clipping 168 471 Computer Graphics, KKU. Lecture 8

  4. Clipping Lines Against Rectangles 168 471 Computer Graphics, KKU. Lecture 8

  5. Clipping Rules 168 471 Computer Graphics, KKU. Lecture 8

  6. Computing Intersections 168 471 Computer Graphics, KKU. Lecture 8

  7. Cohen-Sutherland Algorithm 168 471 Computer Graphics, KKU. Lecture 8

  8. Outcodes 168 471 Computer Graphics, KKU. Lecture 8

  9. Outcode Computation typedef unsigned int outcode; enum {TOP = 0x1, BOTTOM = 0x2, RIGHT = 0x4, LEFT = 0x8} outcode CompOutCode( double x, double y, double xmin, double xmax, double ymin, double ymax) { outcode code = 0; if ( y > ymax ) code |= TOP; else if ( y < ymin ) code |= BOTTOM; if ( x > xmax ) code |= RIGHT; else if ( x < xmin ) code |= LEFT; return code; } 168 471 Computer Graphics, KKU. Lecture 8

  10. Cohen-Sutherland Procedures 168 471 Computer Graphics, KKU. Lecture 8

  11. Cohen-Sutherland Procedures 168 471 Computer Graphics, KKU. Lecture 8

  12. Cohen-Sutherland Algorithm 168 471 Computer Graphics, KKU. Lecture 8

  13. Cohen-Sutherland Algorithm (cont.) 168 471 Computer Graphics, KKU. Lecture 8

  14. Cohen-Sutherland Procedures 168 471 Computer Graphics, KKU. Lecture 8

  15. Parametric Line-Clipping Algorithm • Introduced by Cyrud and Beck in 1978 • Efficiently improved by Liang and Barsky • Essentially find the parameter t from P(t) = P0 + (P1-P0)t 168 471 Computer Graphics, KKU. Lecture 8

  16. Parametric Line-Clipping Algorithm (cont.) • Formally, intersections can be classified as PE (potentially entering) and PL (potentially leaving) on the basis of the angle between P0P1 and Ni • Determine tE or tL for each intersection • Select the line segment that has maximum tE and minimum tL • If tE > tL, then trivially rejected 168 471 Computer Graphics, KKU. Lecture 8

  17. Parametric Line-Clipping Algorithm (cont.) 168 471 Computer Graphics, KKU. Lecture 8

  18. Cyrus-Beck Algorithm (Pseudocode) 168 471 Computer Graphics, KKU. Lecture 8

  19. Clipping Circles and Ellipses • Firstly, do a trivial accept/reject test by intersecting the circle’s/elleipse’s extent with the clip rectengle. • If intersection occurs, divide it into and do the trivial accept/reject test for each. • If scan conversion is fast or if the circle is not too large, scissoring on a pixel-by-pixel basis would be more efficient. 168 471 Computer Graphics, KKU. Lecture 8

  20. Clipping Polygons Example of polygon clipping, (a) Multiple components. (b) Simple convex case. (c) Concave case. 168 471 Computer Graphics, KKU. Lecture 8

  21. Clipping Polygons (cont.) Polygon clipping, edge by edge. (a) Before clipping. (b) Clip on right. (c) Clip on bottom. (d) Clip on left. (e) Clip on top; polygon is fully clipped 168 471 Computer Graphics, KKU. Lecture 8

More Related