Unit – IV 2D Viewing. 2 of 30 Contents Windowing Concepts The viewing pipeline viewing coordinate reference frame, window to view-port coordinate transformation,

Slides:



Advertisements
Similar presentations
Computer Graphics 4: Viewing In 2D
Advertisements

Rezanje črt in poligonov. World window & viewport window viewport screen window world window.
Computer Graphics CLIPPING.
Objectives Define Clipping Various clipping methods. Line clipping methods.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
10/10/02 (c) 2002 University of Wisconsin, CS 559 Last Time Finished viewing: Now you know how to: –Define a region of space that you wish to view – the.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
CS 551 / 645: Introductory Computer Graphics Clipping Lines and Polygons.
Course Website: Computer Graphics 4: Viewing In 2D.
1 Clipping. 2 Transformation Sequence X Y Z X Y Z X Y Z X Y Z Object Coords. Eye Coords. Clip Coords. Normalized Device Coords. Screen Coords. Implementation:
Two-Dimensional Viewing Jehee Lee Seoul National University.
Computer Graphics : Clipping
Computer Graphics Viewing.
Clipping CSE 403 Computer Graphics Cohen Sutherland Algorithm (Line)
Viewing & Clipping In 2D. 2 of 44 Contents Windowing Concepts Clipping –Introduction –Brute Force –Cohen-Sutherland Clipping Algorithm Area Clipping –Sutherland-Hodgman.
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
2D Viewing and Projection
2 D viewing Prepared by Elizabeth Isaac DCS, RSET.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Two Dimensional Viewing Dr. Eng. Farag Elnagahy
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
Computer Graphics Clipping Cohen Sutherland Algorithm (Line) Cyrus-Back Algorithm (Line) Sutherland-Hodgeman Algorithm (Polygon) Cohen Sutherland Algorithm.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Clipping.
University College Dublin1 Clipping u Clipping is the removal of all objects or part of objects in a modelled scene that are outside the real-world window.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.
1 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
2-Dimension Viewing and Clipping
Clipping Apart from clipping to the view volume, clipping is a basic operation in many other algorithms –Breaking space up into chunks –2D drawing and.
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
Two-Dimensional Viewing
Clipping: Clipping is a process of dividing an object into visible and invisible positions and displaying the visible portion and discarding the invisible.
Two Dimensional Viewing
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 2D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Windows, Viewports, and Clipping
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 1 1.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
EEL Introduction to Computer Graphics
1 Computer Graphics Clipping Fall FCC Line Clipping What happens when one or both endpoints of a line segment are not inside the specified drawing.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
2D Viewing.
Clipping Primitives. Clipping line Clipping rectangle: – x min to x max – y min to y max A point (x,y) lies within a clip rectangle and thus displayed.
Graphics Graphics & Graphical Programming Lecture 23 - Viewing & Clipping.
A.Aruna/Assistant Professor/SNSCE
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Two-Dimensional Viewing Hearn & Baker Chapter 6
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphic 2 D Viewing.
Computer Graphics Clipping.
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
2D Viewing & Clipping 한신대 류승택
Concepts, algorithms for clipping
Graphics Pipeline Clipping
WINDOWING AND CLIPPING
Computer Graphics : Viewing In 2D
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Two Dimensional Viewing and Clipping.
Clipping Clipping Sutherland-Hodgman Clipping
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Clipping University of British Columbia CPSC 314 Computer Graphics
COMPUTER GRAPHICS Clipping
Presentation transcript:

Unit – IV 2D Viewing.

2 of 30 Contents Windowing Concepts The viewing pipeline viewing coordinate reference frame, window to view-port coordinate transformation, viewing functions Line Clipping –Introduction –Cohen-Sutherland Clipping Algorithm –Cyrus-beck line clipping algorithms Polygon Clipping –Sutherland-Hodgman Area Clipping Algorithm

3 of 30 Where we require clipping? An architect may have a graphics program to draw an entire building but be interested in only the swimming pool.

4 of 30 Viewing in 2D - Viewport Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels. Display Device

5 of 30 The computer is used in design applications because it can easily and accurately create, store and modify very complex drawings. When drawings are too complex, however, they become difficult to read. In such situations it is useful to display only those portions of the drawing that are of immediate interest. Sometimes, it is desirable to enlarge these portions to take full advantage of the available display surface. The method for selecting and enlarging portions of a drawing is called windowing. The technique for not showing the part of the drawing which one is not interested is called a clipping.

6 of 30 Windowing I A scene is made up of a collection of objects specified in world coordinates World Coordinates

7 of 30 Window A world coordinate area selected for display is called a window. wy max wy min wx min wx max Window World Coordinates

8 of 30 View port An area on a display device to which a window is mapped is called a view port. Vy max Vy min Vx min Vx max Device Coordinates View port

9 of 30 VIDEOCON Display Screen View Port

10 of 30 The window defines what is to be viewed. And the view port defines where it is to be displayed. Window and view ports are rectangles in standard positions, with rectangle edges parallel to the coordinate axes.

11 of 30 Window to viewport mapping or windowing transformation. The mapping of a part of a world coordinate scene to device coordinates is referred to as a viewing transformation. 2-d viewing transformation is also referred as window to view port or windowing transformation. Y w max Y w min X w min X w max window Y v max Y v min X v min X v max View port

12 of 30 The Viewing Pipeline Window A world-coordinate area selected for display. defines what is to be viewed Viewport An area on a display device to which a window is mapped. defines where it is to be displayed Viewing transformation The mapping of a part of a world-coordinate scene to device coordinates. A window could be a rectangle to have any orientation.

13 of 30

14 of 30

15 of 30 2D Viewing Pipeline To make the viewing process independent of the requirements of any output device, graphics systems convert object descriptions to normalized coordinates range from 0 to 1

16 of 30 Window to viewing coordinate transformation  First, we construct the scene in world coordinates using the output primitives and attributes.  Next, to obtain a particular orientation for the window, we can set up a 2-dimenstional viewing coordinate system in the world coordinate plane and define a window in the viewing coordinate system.  The viewing coordinate reference frame is used to provide a method for setting up arbitrary orientation of rectangular windows.  Once the viewing reference frame is established, we can transform descriptions in world coordinates to viewing coordinates( in the range from 0 to 1) and map viewing coordinate description of the scene to normalized coordinates.  At the final step, all parts of the picture that lie outside the view port are clipped and the contents of the view port are transferred to device coordinates.

17 of 30 Cntd.. By changing the position of the view port, we can view objects at different positions on the display area of an output device. Also, by varying the size of view port, we can change the size and proportions of displayed objects. We achieve zooming effects by successively mapping different sized windows on a fixed size view port. As the windows are made smaller, we zoom in on some part of a scene to view details that are not shown with larger windows. Similarly, more overview is obtained by zooming out from a section of a scene with successively larger windows.

18 of 30 The Viewing Pipeline M wc,vc = R. T

19 of 30

20 of 30

21 of 30 (0,0) (100,50) (0,25) (50,50) So S x = 50/100 = ½ And S y = 25/50 = ½ XW min,YW min XW max,YW max XV min,YV min XV max,YV max XV max -XV min XW max -XW min Sx=Sx= YV max -YV min YW max -YW min Sy=Sy=

22 of 30 Window to View port coordinate Transformation

23 of 30

24 of 30 Window-to-Viewport Coordinate Transformation To map a point in the window at world position (xw, yw ) in the associated view port (xv, yv ) we use the concept of relative distance.

25 of 30 Workstation transformation Mapping selected parts of a scene in normalized coordinates to different video monitors with workstation transformations

26 of 30 Clipping Operations Clipping Identify those portions of a picture that are either inside or outside of a specified region of space. Clip window The region against which an object is to be clipped. The shape of clip window Applications of clipping World-coordinate clipping

27 of 30 Clipping Operations Viewport clipping It can reduce calculations by allowing concatenation of viewing and geometric transformation matrices. Types of clipping Point clipping Line clipping Area (Polygon) clipping Curve clipping Text clipping Point clipping (Rectangular clip window)

28 of 30 Point clipping Point clipping: Remove points outside window. –A point is either entirely inside the region or not Assuming that the clip window is a rectangle in standard position, we save a point p=(x,y) for display if the following inequalities are satisfied: Where the edges of the clip window ( xw min, xw max, yw min, yw max ) can be either world coordinate window boundaries or viewport boundaries. If any one of these four inequalities is not satisfied, the point is clipped (not saved for display)

29 of 30 For a point (x,y) to be inside the clip rectangle: Point Clipping

30 of 30 Line Clipping Basic calculations: –Is an endpoint inside or outside the clipping window? –Find the point of intersection, if any, between a line segment and an edge of the clipping window. Both endpoints inside: trivial accept One inside: find intersection and clip Both outside: either clip or reject

31 of 30 Line Clipping For the image below consider which lines and points should be kept and which ones should be clipped wy max wy min wx min wx max Window P1P1 P2P2 P3P3 P6P6 P5P5 P7P7 P 10 P9P9 P4P4 P8P8

32 of 30 Point Clipping Easy - a point ( x,y ) is not clipped if: wx min ≤ x ≤ wx max AND wy min ≤ y ≤ wy max otherwise it is clipped wy max wy min wx min wx max Window P1P1 P2P2 P5P5 P7P7 P 10 P9P9 P4P4 P8P8 Clipped Points Within the Window are Not Clipped Clipped

33 of 30 Line Clipping Harder - examine the end-points of each line to see if they are in the window or not SituationSolutionExample Both end-points inside the window Don’t clip One end-point inside the window, one outside Must clip Both end-points outside the window Must clip

34 of 30 Cohen-Sutherland Clipping Algorithm An efficient line clipping algorithm The key advantage of the algorithm is that it vastly reduces the number of line intersections that must be calculated Dr. Ivan E. Sutherland co-developed the Cohen- Sutherland clipping algorithm. Sutherland is a graphics giant and includes amongst his achievements the invention of the head mounted display.

35 of 30 Cases for clipping lines Line Clipping

36 of 30 Cases for clipping lines Line Clipping

37 of 30 Cases for clipping lines Line Clipping

38 of 30 Cases for clipping lines Line Clipping

39 of 30 Cases for clipping lines Line Clipping

40 of 30 Cases for clipping lines Line Clipping

41 of 30 Cohen-Sutherland: World Division World space is divided into regions based on the window boundaries –Each region has a unique four bit region code –Region codes indicate the position of the regions with respect to the window Window

42 of 30 1.End-points pairs are checked for trivial acceptance or rejection using outcode; 2.If not trivially accepted or rejected, divide the line segment into two at a clip edge; 3.Iteratively clipped by test trivial-acceptance or trivial-rejection, and divided into two segments until completely inside or trivial-rejection. A B C D E F G H I Steps for Cohen-Sutherland alg.

43 of 30 Cohen-Sutherland: Labelling Every end-point is labelled with the appropriate region code wy max wy min wx min wx max Window P 3 [0001] P 6 [0000] P 5 [0000] P 7 [0001] P 10 [0100] P 9 [0000] P 4 [1000] P 8 [0010] P 12 [0010] P 11 [1010] P 13 [0101] P 14 [0110]

44 of 30 Cohen-Sutherland: Lines In The Window Lines completely contained within the window boundaries have region code [0000] for both end-points so are not clipped wy max wy min wx min wx max Window P 3 [0001] P 6 [0000] P 5 [0000] P 7 [0001] P 10 [0100] P 9 [0000] P 4 [1000] P 8 [0010] P 12 [0010] P 11 [1010] P 13 [0101] P 14 [0110]

45 of 30 Cohen-Sutherland: Lines Outside The Window Any lines with a common set bit in the region codes of both end-points can be clipped –The AND operation can efficiently check this wy max wy min wx min wx max Window P 3 [0001] P 6 [0000] P 5 [0000] P 7 [0001] P 10 [0100] P 9 [0000] P 4 [1000] P 8 [0010] P 12 [0010] P 11 [1010] P 13 [0101] P 14 [0110]

46 of 30 Cohen-Sutherland: Other Lines Lines that cannot be identified as completely inside or outside the window may or may not cross the window interior These lines are processed as follows: –Compare an end-point outside the window to a boundary (choose any order in which to consider boundaries e.g. left, right, bottom, top) and determine how much can be discarded –If the remainder of the line is entirely inside or outside the window, retain it or clip it respectively

47 of 30 Cohen-Sutherland: Other Lines (cont…) –Otherwise, compare the remainder of the line against the other window boundaries –Continue until the line is either discarded or a segment inside the window is found We can use the region codes to determine which window boundaries should be considered for intersection –To check if a line crosses a particular boundary we compare the appropriate bits in the region codes of its end-points –If one of these is a 1 and the other is a 0 then the line crosses the boundary

48 of 30 Cohen-Sutherland Examples Consider the line P 9 to P 10 below –Start at P 10 –From the region codes of the two end-points we know the line doesn’t cross the left or right boundary –Calculate the intersection of the line with the bottom boundary to generate point P 10 ’ –The line P 9 to P 10 ’ is completely inside the window so is retained wy max wy min wx min wx max Window P 10 [0100] P 9 [0000] P 10 ’ [0000] P 9 [0000]

49 of 30 Cohen-Sutherland Examples (cont…) Consider the line P 3 to P 4 below –Start at P 4 –From the region codes of the two end-points we know the line crosses the left boundary so calculate the intersection point to generate P 4 ’ –The line P 3 to P 4 ’ is completely outside the window so is clipped wy max wy min wx min wx max Window P 4 ’ [1001] P 3 [0001] P 4 [1000] P 3 [0001]

50 of 30 Cohen-Sutherland Examples (cont…) Consider the line P 7 to P 8 below –Start at P 7 –From the two region codes of the two end-points we know the line crosses the left boundary so calculate the intersection point to generate P 7 ’ wy max wy min wx min wx max Window P 7 ’ [0001] P 7 [0001] P 8 [0010] P 8 ’ [0010]

51 of 30 Cohen-Sutherland Examples (cont…) Consider the line P 7 ’ to P 8 –Start at P 8 –Calculate the intersection with the right boundary to generate P 8 ’ –P 7 ’ to P 8 ’ is inside the window so is retained wy max wy min wx min wx max Window P 7 ’ [0001] P 7 [0001] P 8 [0010] P 8 ’ [0010]

52 of 30 Cohen-Sutherland Worked Example wy max wy min wx min wx max Window

53 of 30 Calculating Line Intersections Intersection points with the window boundaries are calculated using the line- equation parameters –Consider a line with the end-points ( x 1, y 1 ) and ( x 2, y 2 ) –The y-coordinate of an intersection with a vertical window boundary can be calculated using: y = y 1 + m (x boundary - x 1 ) where x boundary can be set to either wx min or wx max

54 of 30 Calculating Line Intersections (cont…) –The x-coordinate of an intersection with a horizontal window boundary can be calculated using: x = x 1 + (y boundary - y 1 ) / m where y boundary can be set to either wy min or wy max –m is the slope of the line in question and can be calculated as m = (y 2 - y 1 ) / (x 2 - x 1 )

55 of 30 Initial Condition Sutherland-Hodgeman Algo. Clip Against Right Clipping Boundary Clip Against Top Clipping Boundary The Clipped Polygon Clip Against Bottom Clipping Boundary Clip Against Left Clipping Boundary

56 of 30 Polygon Clipping v1 v2 v1’ out in Output: v1’ and v2 v1 v2 in Output: v2 v1v2 v1’ in out Output: v1’ v1 v2 out Output: none outside inside Sutherland-Hodgeman Polygon Clipping against a rectangle (or a window) For each stage, the boundary clipper divides the plane into an inside half-plane And outside half-plane Inside half-plane contains the clipping window; Outside half-plane doesn’t. Given an edge going from vertex V[i] to vertex V[i+1], during the transversal, there are four cases (assuming the V[i] has been checked in the previous edge):

57 of 30 Case 1 4 Cases of Polygon Clipping Case 2 Case 3 Case 4

58 of 30 Cohen-Sutherland – polygons s p InsideOutside s p InsideOutside s p InsideOutside s p InsideOutside 1 st Output i OutputNo Output i 2 nd Output Output

59 of 30 Area Clipping Similarly to lines, areas must be clipped to a window boundary Consideration must be taken as to which portions of the area must be clipped

60 of 30 Sutherland-Hodgman Area Clipping Algorithm A technique for clipping areas developed by Sutherland & Hodgman Put simply the polygon is clipped by comparing it against each boundary in turn Original AreaClip LeftClip RightClip BottomClip Top Sutherland turns up again. This time with Gary Hodgman with whom he worked at the first ever graphics company Evans & Sutherland

61 of 30 Sutherland-Hodgman Area Clipping Algorithm (cont…) To clip an area against an individual boundary: –Consider each vertex in turn against the boundary –Vertices inside the boundary are saved for clipping against the next boundary –Vertices outside the boundary are clipped –If we proceed from a point inside the boundary to one outside, the intersection of the line with the boundary is saved –If we cross from the outside to the inside intersection point and the vertex are saved

62 of 30 Sutherland-Hodgman Example Each example shows the point being processed (P) and the previous point (S) Saved points define area clipped to the boundary in question S P Save Point P S P Save Point I I P S No Points Saved S P Save Points I & P I

63 of 30 Other Area Clipping Concerns Clipping concave areas can be a little more tricky as often superfluous lines must be removed Clipping curves requires more work –For circles we must find the two intersection points on the window boundary Window

64 of 30 Summary Objects within a scene must be clipped to display the scene in a window Because there are can be so many objects clipping must be extremely efficient The Cohen-Sutherland algorithm can be used for line clipping The Sutherland-Hodgman algorithm can be used for area clipping

65 of 30

66 of 30 Cohen-Sutherland Clipping Algorithm VI Let’s consider the lines remaining below wy max wy min wx min wx max Window P 3 [0001] P 6 [0000] P 5 [0000] P 7 [0001] P 10 [0100] P 9 [0000] P 4 [1000] P 8 [0010] P 12 [0010] P 11 [1010] P 13 [0101] P 14 [0110]

67 of 30 Cohen-Sutherland Clipping Algorithm Easy - a point ( x,y ) is not clipped if: wx min ≤ x ≤ wx max AND wy min ≤ y ≤ wy max otherwise it is clipped wy max wy min wx min wx max Window P1P1 P2P2 P5P5 P7P7 P 10 P9P9 P4P4 P8P8 Clipped Points Within the Window are Not Clipped Clipped

68 of 30 Clipping Point clipping is easy: –For point ( x,y ) the point is not clipped if wx min ≤ x ≤ wx max AND wy min ≤ y ≤ wy max wy max wy min wx min wx max Before Clipping Window P1P1 P2P2 P3P3 P6P6 P5P5 P7P7 P 10 P9P9 P4P4 P8P8

69 of 30 Cohen-Sutherland – polygons s p InsideOutside s p InsideOutside s p InsideOutside s p InsideOutside 1 st Output i OutputNo Output i 2 nd Output Output

Polygon Clipping.

71 of 30 Ex: Simple Convex

72 of 30 Ex: Multiple Components

73 of 30 Nonconvex with Many Edges

74 of 30 Polygons : Before Clipping

75 of 30 Polygons: Clip on Top Top Clip Boundary

76 of 30 Polygons: Clip on Right Right Clip Boundary

77 of 30 Polygons: Clip on Bottom Bottom Clip Boundary

78 of 30 Polygons: Clip on Left Left Clip Boundary

79 of 30 Polygons: Clipped Polygon

80 of 30 Begin Animated Recap

81 of 30 Polygons: Before Clipping

82 of 30 Polygons: Clip on Top Top Clip Boundary

83 of 30 Polygons: Clip on Top Top Clip Boundary

84 of 30 Polygons: Clip on Right Right Clip Boundary

85 of 30 Polygons: Clip on Right Right Clip Boundary

86 of 30 Polygons: Clip on Bottom Bottom Clip Boundary

87 of 30 Polygons: Clip on Bottom Bottom Clip Boundary

88 of 30 Polygons: Clip on left Left Clip Boundary

89 of 30 Polygons: Clip on left Left Clip Boundary

90 of 30 Polygons: Fully Clipped

91 of 30 Polygons: Clip on Left Left Clip Boundary

92 of 30 Polygons: Clipped Polygon

93 of 30 End Animated Recap

Hodgeman-Sutherland

95 of 30 Polygons: Case 1 INOUT S i output P

Case 1: S out; P in Action: Output i and P

97 of 30 Polygons: Case 2 (no output) P S IN OUT

Case 2: S & P both in Action: output p

99 of 30 Polygons: Case 3 P : second output i: first output S IN OUT

Case 3: S IN ; P OUT Action: Output i

101 of 30 Polygons: Case 4 Polygon being clipped P: output Clip boundary S IN OUT

Case 4: S & P both out Action: None

103 of 30 Case 2 : S & P both IN Action: Output P Case 3: S IN ; P OUT Action: Output i ( S already output under Case 1) Case 4: S & P both OUT Action: None Case 1: S OUT ; P IN Action: Output i and P

104 of 30 Hodgeman-Sutherland

105 of 30 Hodgeman-Sutherland

106 of 30 Hodgeman-Sutherland: Top

107 of 30 Hodgeman-Sutherland: Top

108 of 30 Hodgeman-Sutherland: Bottom

109 of 30 Hodgeman-Sutherland: Bottom

110 of 30 Hodgeman-Sutherland: Bottom

111 of 30 Hodgeman-Sutherland: Right

112 of 30 This case is trivial: do nothing Hodgeman-Sutherland: Right

113 of 30 Hodgeman-Sutherland: Left

114 of 30 Hodgeman-Sutherland: Left

115 of 30 Hodgeman-Sutherland: Left

116 of 30 Hodgeman-Sutherland: Done

117 of 30 Begin Animated Recap

118 of 30

119 of 30 Done Top

120 of 30

121 of 30 Done Bottom

122 of 30 Nothing needs to be clipped against Right

123 of 30

124 of 30 End Animated Recap

125 of 30 Hodgeman-Sutherland: Done

126 of 30 Hodgeman-Sutherland Problem Extra Lines

127 of 30 Correct Result How to Fix Up?

128 of 30 Distinguish Between Case 2 S i output P INOUT

129 of 30 And, Case 4 P : second output i : first output S INOUT

130 of 30 Distingish Between Case 2 S P INOUT

131 of 30 And, Case 4 P : second output S INOUT

132 of 30 Extended H-S Algorithm Tag the different new vertices Call the one generated on transition from IN to OUT Call the one generated on transition from OUT to IN Starting from OUT, connect as soon as is generated

133 of 30 Example of Extended Algo INOUT

134 of 30 Result INOUT

135 of 30 Extended H-S Algorithm Connect and as soon as the. is generated Generate next polygon beginning with next, i.e.,

Another Polygon Clipping Algorithm Weiler-Atherton Clipping

137 of 30 Another approach to polygon clipping No extra clipping outside window Works for arbitrary shapes Avoids degenerate polygons Weiler-Atherton Polygon Clipping

138 of 30 Weiler-Atherton Clipping Clip Polygon (ep) Subject Polygon (sp)

139 of 30 Gives “Right” Answer

140 of 30 Start at first (inside) vertex Traverse polygon until hitting a window boundary Output intersection point i Turn right Follow window boundary until next intersection Weiler-Atherton Clipping

141 of 30 Output second intersection Turn right, again, and follow subject polygon until closed Continue on subject polygon from first intersection point. Repeat processing until complete Weiler-Atherton Clipping

142 of 30 Approximate description Can be improved Weiler-Atherton Clipping

143 of 30 Generalizations of W-A Can be extended to complex situations, arbitrary windows Stability issues can arise for such cases

General Boolean Operations via Boundary Representations (B-reps)

General Clipping with abitrary polygons

146 of 30 General Boolean Operations A B

147 of 30 A B

148 of 30 B

149 of 30 A B

150 of 30

151 of 30 A B A

152 of 30 A

153 of 30

154 of 30 A B

155 of 30 A B

156 of 30

157 of 30 A B

158 of 30

159 of 30 B on

160 of 30

161 of 30 A B on

162 of 30

163 of 30 ((anti-)shared ) anti-sharedshared

164 of 30 A B

165 of 30

166 of 30 A B

167 of 30

168 of 30 A B

169 of 30

The End Polygon Clipping Lecture Set 5