210 likes | 229 Views
Explore analytical and parametric algorithms for clipping in computer graphics. Learn Cohen-Sutherland and Cyrus-Beck methods, with examples on circles, ellipses, and polygons. Enhance your understanding of line clipping and intersection computation with practical procedures and outcode computations. Discover the intricacies of clipping rules against rectangles and master the application of algorithms for precise rendering. Dive deep into pixel-by-pixel scissoring and detailed explanations of various clipping approaches. Unlock the power of advanced techniques in computer graphics with valuable insights from KKU lectures.
E N D
Clipping on a Raster Display 168 471 Computer Graphics, KKU. Lecture 8
Approaches to Clipping 168 471 Computer Graphics, KKU. Lecture 8
Analytical Clipping 168 471 Computer Graphics, KKU. Lecture 8
Clipping Lines Against Rectangles 168 471 Computer Graphics, KKU. Lecture 8
Clipping Rules 168 471 Computer Graphics, KKU. Lecture 8
Computing Intersections 168 471 Computer Graphics, KKU. Lecture 8
Cohen-Sutherland Algorithm 168 471 Computer Graphics, KKU. Lecture 8
Outcodes 168 471 Computer Graphics, KKU. Lecture 8
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
Cohen-Sutherland Procedures 168 471 Computer Graphics, KKU. Lecture 8
Cohen-Sutherland Procedures 168 471 Computer Graphics, KKU. Lecture 8
Cohen-Sutherland Algorithm 168 471 Computer Graphics, KKU. Lecture 8
Cohen-Sutherland Algorithm (cont.) 168 471 Computer Graphics, KKU. Lecture 8
Cohen-Sutherland Procedures 168 471 Computer Graphics, KKU. Lecture 8
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
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
Parametric Line-Clipping Algorithm (cont.) 168 471 Computer Graphics, KKU. Lecture 8
Cyrus-Beck Algorithm (Pseudocode) 168 471 Computer Graphics, KKU. Lecture 8
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
Clipping Polygons Example of polygon clipping, (a) Multiple components. (b) Simple convex case. (c) Concave case. 168 471 Computer Graphics, KKU. Lecture 8
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