29
Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition Chapter 14

Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Embed Size (px)

DESCRIPTION

Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition. Chapter 14. Figure 14.1: (a) A clipping rectangle R and four straight line segments with their parts clipped to R colored (b) Nine regions of the plane by outcode. - PowerPoint PPT Presentation

Citation preview

Page 1: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Computer Graphics Through OpenGL: From Theory to

Experiments, Second Edition

Chapter 14

Page 2: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.1: (a) A clipping rectangle R and four straight line segments with their partsclipped to R colored (b) Nine regions of the plane by outcode.

Page 3: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.2: Cohen-Sutherland, called on segment p1p2, recursively calls itself on p2q1,q1q2 and q2q3, successively.

Page 4: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.3: Clipping a semi-infinite segment to a rectangle.

Page 5: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.4: Clipping aline segment to anaxis-aligned box.

Page 6: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.5: Cohen-Sutherland intersection computation.

Page 7: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.6: A pipeline of clippers.

Page 8: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.7: The left clipper in action: input = {v0, v1, v2, v3}, output ={v0, v1, v2, w, w’}.

Page 9: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.8: Output of a pair of successive vertices (equivalently, edge) entering the leftclipper. Note both in-out and out-in dispositions have a special case, labeled (ii), wherethe vertex on the inside actually lies on L.

Page 10: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.9: Applying the clipping rules.

Page 11: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.10: The right clipper consumes the first two vertices v1 and v2 entering intoit from the left clipper to output w’’ and v2.

Page 12: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.11: An m x n raster of pixels and a rasterized straight line segment.

Page 13: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.12: Screenshotof DDA.cpp.

Page 14: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.13: The larger circles are pixel centers. (a) Pixel (i, j) shown filled blue hasjust been chosen, the two candidate pixels for the next step are filled orange (b) Diagramfor Example 14.3.

Page 15: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.14: Discrim-inating the position of apoint with respect to asegment: S is bold, whilethe straight line through itis thin.

Page 16: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.15: Intersections of R with the boundary of P are labeled with theirrespective ranks.

Page 17: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.16: Testing parity: the points p3 and p4 require handling a singularity.

Page 18: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.17: Applying the parity test: the integer label beneath a segment of Rindicates the number of intersections of R with the boundary of P prior to reaching thatsegment. The reason for the change from 5 to 7 after p6 and from 9 to 11 after edge w’ isexplained in the text. The edges w and w’ are not labeled because they lie on theboundary.

Page 19: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.18: The scan line as a ray with parities along segments indicated. Pixels fillthe polygon according to the parity test: pixels in the polygon are drawn solid, others arehollow.

Page 20: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.19: Abuttingpolygons.

Page 21: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.20: The non-horizontal edges of P are labeled left or right, while thehorizontal ones top or bottom. P owns the part of the boundary it shares with Q; P doesnot own the part of the boundary it shares with Q’.

Page 22: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.21: Problems with Version 1.

Page 23: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.22: Counting intersections according to Version 2: shown are eight scan lines,their intersections with the polygon boundary and the number of times each intersectionpoint appears in the sorted list for that scan line, according to statements 1 and 2 ofalgorithm Version 2. Polygon vertices and intersection points are not named to avoidclutter.

Page 24: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.23: Edgecoherence.

Page 25: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.24: The AEL values for scan lines 0, 4 and 5 for a polygon P in a 19 x 11raster. Pixels are drawn as hollow circles only for these three scan lines.

Page 26: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.25: Edge table for the polygon P of Figure 14.24.

Page 27: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.26: (a) Typ-ical dispositions of a leftand right edge with respectto a run of pixels (b) Theone exceptional case wherea left and a right edgemeet at a common lowerendpoint.

Page 28: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.27: Flood-fill: (a) Initially (b) Fill pixels 4-adjacent to p (c) Fill pixels4-adjacent to the ones filled in the previous step. The starred pixel of (b) is examined byboth its south and west neighbors at this step.

Page 29: Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition

Figure 14.28: Flood-fillfails on the polygon Qwhose boundary is drawn.