Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display
Computer Graphics, KKU. Lecture 82 Approaches to Clipping
Computer Graphics, KKU. Lecture 83 Analytical Clipping
Computer Graphics, KKU. Lecture 84 Clipping Lines Against Rectangles
Computer Graphics, KKU. Lecture 85 Clipping Rules
Computer Graphics, KKU. Lecture 86 Computing Intersections
Computer Graphics, KKU. Lecture 87 Cohen-Sutherland Algorithm
Computer Graphics, KKU. Lecture 88 Outcodes
Computer Graphics, KKU. Lecture 89 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; }
Computer Graphics, KKU. Lecture 810 Cohen-Sutherland Procedures
Computer Graphics, KKU. Lecture 811 Cohen-Sutherland Procedures
Computer Graphics, KKU. Lecture 812 Cohen-Sutherland Algorithm
Computer Graphics, KKU. Lecture 813 Cohen-Sutherland Algorithm (cont.)
Computer Graphics, KKU. Lecture 814 Cohen-Sutherland Procedures
Computer Graphics, KKU. Lecture 815 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) = P 0 + (P 1 -P 0 )t
Computer Graphics, KKU. Lecture 816 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 P 0 P 1 and N i Determine t E or t L for each intersection Select the line segment that has maximum t E and minimum t L If t E > t L, then trivially rejected
Computer Graphics, KKU. Lecture 817 Parametric Line-Clipping Algorithm (cont.)
Computer Graphics, KKU. Lecture 818 Cyrus-Beck Algorithm (Pseudocode)
Computer Graphics, KKU. Lecture 819 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.
Computer Graphics, KKU. Lecture 820 Clipping Polygons Example of polygon clipping, (a) Multiple components. (b) Simple convex case. (c) Concave case.
Computer Graphics, KKU. Lecture 821 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