Clipping When? 2D clipping 2D clipping ? Part of the primitive is inside the window defined in WCS Remark: clipping is done to avoid the cost of future transformations on those parts of the primitives that are not visible in the image Methods 1. 2. 3. Analytic During the scan conversion Copy pixels from one memory region to another memory region Remark: Met 1 for lines and polygons, Met 2 for other primitives Point clipping Suppose a rectangular window with the corners (xmin,ymin) and (xmax,ymax) P(x,y) is visible Ù xmin<= x<=xmax, ymin<=y <=ymax Simple alg. for line segments Suppose F=rectangular window; ? PQ/F Acceptance / rejection tests Accept if both ends of the segment are visible Reject if both ends of the segment are un the same part of the window (left, right, top, bottom) Simple alg + tests = efficient alg when the no. of interior or exterior segments is big Acceptance/rejection tests and coding Examples Cohen-Sutherland alg. Example Examples Examples Examples Bisection algorithm Principle: if the tests for acceptance or rejection fail on PQ then PQ is divided in two segments, PR, RQ, R=(P+Q)/2 ? PR, PQ accepted/rejected … Remark: segments are accepted or rejected at most after log2 N steps, where N is the dimension in pixels of the discretized version of the segment PQ Parametric line clipping algorithm (Cyrus-Beck algorithm) Suppose: trigonometric sense An edge of the window is inside the window The normal N to an edge E is oriented towards window exterior The support line for a given segment P1P0 is P(t)=P0+(P1-P0)t, t in R. Suppose x0<x1 Cyrus-Beck algorithm CB alg - computations Simplifying the computations Nicholl-Lee-Nicholl algorithm Code of NLN algorithm Code of NLN algorithm Code of NLN algorithm Weiler-Atherton alg. Polygon clipping Polygon clipping Polygon clipping Tests for acceptance/rejection: method of bounded aria by finding the smallest rectagle that surrounds the polygon Sutherland-Hodgman algorithm: Divide-et-impera strategy No. stages = no. edges of the clipping polygon I: list of initial vertex O: list of final vertex Bounded aria method SH algorithm SH Algorithm SH Algorithm SH algorithm SH algorithm SH algorithm Liang Barsky algorithm Suppose F=rectangle, vertex {P1,P2,…Pn} numbered in trigonometric order ? {P’1,P’2,…P’n} defining the clipped polygon Interior region 2 = corner region Interior region 3 = edge region Remark: an edge is entering in a corner region => the corner is added to the output list LB alg LB alg: passing through a corner region LB alg LB alg 3d Clipping 3d clipping 3d clipping With respect to the viewing volume Methods: generalization from 2d->3d: CohenSutherland, bisection, Cyrus-Beck Cohen-Sutherlang alg: using the canonic volume 3d clipping, perspective CS Alg - codes Bit Canonic vol./ parallel proj. Canonic vol./ perspective proj. 3d clipping CS alg - computations Cyrus-Beck alg. CB alg - code