Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)

Slides:



Advertisements
Similar presentations
Rezanje črt in poligonov. World window & viewport window viewport screen window world window.
Advertisements

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 30, D Clipping 1/14 Clipping (pages , )
Computer Graphics CLIPPING.
Objectives Define Clipping Various clipping methods. Line clipping methods.
Line clipping: Line clipping algorithm is method of eliminate lines of outside area of the object,so outside of object viewing is Removed. Typically, any.
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.
CS 445 / 645 Introduction to Computer Graphics Lecture 9 Clipping Clipping.
3/2/04© University of Wisconsin, CS559 Spring 2004 Last Time General Perspective –Methods for specifying the view volume As a set of clip planes As a field.
David Breen, William Regli and Maxim Peysakhov
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.
Line Clipping Algorithms. A Cases for Clipping Lines E B H C G J I clip rectangle 2Prepared by Narendra V G CSE MIT.
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,
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
March 1, 2009Dr. Muhammed Al-Mulhem1 ICS 415 Computer Graphics Clipping Dr. Muhammed Al-Mulhem March 1, 2009 Dr. Muhammed Al-Mulhem March 1, 2009.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Clipping Week 8, Wed Mar.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Clipping II, Hidden Surfaces.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Interpolation Clipping.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
Visibility culling – Clipping. The visibility problem What polygons are visible? There are few visible polygons. –Avoid redundant processing Three classes.
1 Clipping and Hidden Surfaces CS-184: Computer Graphics Prof. James O’Brien.
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.
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.
Windowing and clipping
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.
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
CSE Real Time Rendering Week 9. Post Geometry Shaders Courtesy: E. Angel and D. Shreiner – Interactive Computer Graphics 6E © Addison-Wesley 2012.
Clipping Computer Graphics Cohen Sutherland Algorithm (Line)
10/19/04© University of Wisconsin, CS559 Fall 2004 Last Time Clipping –Why we care –Sutherland-Hodgman –Cohen-Sutherland –Intuition for Liang-Barsky Homework.
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.
Computer Graphics Lecture 20 Fasih ur Rehman. Last Class Clipping – What is clipping – Why we do clipping – How clipping is done.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
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
Clipping. Before clipping… After clipping… Point Clipping Display P = (x, y) if xw min
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphics Clipping.
Computer Graphics CC416 Week 13 Clipping.
CS 551 / 645: Introductory Computer Graphics
Concepts, Algorithms for line clipping
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Concepts, algorithms for clipping
Graphics Pipeline Clipping
Computer Graphics : Viewing In 2D
Clipping Computer Graphics Cohen Sutherland Algorithm (Line)
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Segment Clipping Simple algorithm. For each segment compute the intersection with the four sides of the rectangle, and then determine which sub-segment.
Clipping University of British Columbia CPSC 314 Computer Graphics
Presentation transcript:

Dr. Scott Schaefer Clipping Lines

2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)

3/94 Clipping Points Given a point (x, y)and clipping window (x min, y min ), (x max, y max ), determine if the point should be drawn (x min, y min ) (x max, y max ) (x,y)

4/94 Clipping Points Given a point (x, y)and clipping window (x min, y min ), (x max, y max ), determine if the point should be drawn (x min, y min ) (x max, y max ) (x,y) x min <=x<=x max ? y min <=y<=y max ?

5/94 Clipping Points Given a point (x, y)and clipping window (x min, y min ), (x max, y max ), determine if the point should be drawn (x 1, y 1 ) (x 2, y 2 ) (x min, y min ) (x max, y max ) x min <=x<=x max ? y min <=y<=y max ?

6/94 Clipping Points Given a point (x, y)and clipping window (x min, y min ), (x max, y max ), determine if the point should be drawn (x min, y min ) (x max, y max ) x min <=x 1 <=x max Yes y min <=y 1 <=y max Yes (x 1, y 1 ) (x 2, y 2 )

7/94 Clipping Points Given a point (x, y)and clipping window (x min, y min ), (x max, y max ), determine if the point should be drawn (x min, y min ) (x max, y max ) x min <=x 2 <=x max No y min <=y 2 <=y max Yes (x 1, y 1 ) (x 2, y 2 )

8/94 Clipping Lines

9/94 Clipping Lines

10/94 Clipping Lines Given a line with end-points (x 0, y 0 ), (x 1, y 1 ) and clipping window (x min, y min ), (x max, y max ), determine if line should be drawn and clipped end-points of line to draw. (x 0, y 0 ) (x 1, y 1 ) (x min, y min ) (x max, y max )

11/94 Clipping Lines

12/94 Clipping Lines – Simple Algorithm If both end-points inside rectangle, draw line Otherwise, intersect line with all edges of rectangle clip that point and repeat test

13/94 Clipping Lines – Simple Algorithm

14/94 Clipping Lines – Simple Algorithm

15/94 Clipping Lines – Simple Algorithm

16/94 Clipping Lines – Simple Algorithm

17/94 Clipping Lines – Simple Algorithm

18/94 Clipping Lines – Simple Algorithm

19/94 Clipping Lines – Simple Algorithm

20/94 Clipping Lines – Simple Algorithm

21/94 Clipping Lines – Simple Algorithm

22/94 Clipping Lines – Simple Algorithm

23/94 Clipping Lines – Simple Algorithm

24/94 Window Intersection (x 1, y 1 ), (x 2, y 2 ) intersect with vertical edge at x right  y intersect = y 1 + m(x right – x 1 ) where m=(y 2 -y 1 )/(x 2 -x 1 ) (x 1, y 1 ), (x 2, y 2 ) intersect with horizontal edge at y bottom  x intersect = x 1 + (y bottom – y 1 )/m where m=(y 2 -y 1 )/(x 2 -x 1 )

25/94 Clipping Lines – Simple Algorithm Lots of intersection tests makes algorithm expensive Complicated tests to determine if intersecting rectangle Is there a better way?

26/94 Trivial Accepts Big Optimization: trivial accepts/rejects How can we quickly decide whether line segment is entirely inside window Answer: test both endpoints

27/94 Trivial Accepts Big Optimization: trivial accepts/rejects How can we quickly decide whether line segment is entirely inside window Answer: test both endpoints

28/94 Trivial Rejects How can we know a line is outside of the window Answer: both endpoints on wrong side of same edge, can trivially reject the line

29/94 Trivial Rejects How can we know a line is outside of the window Answer: both endpoints on wrong side of same edge, can trivially reject the line

30/94 Cohen-Sutherland Algorithm Classify p 0, p 1 using region codes c 0, c 1 If, trivially reject If, trivially accept Otherwise reduce to trivial cases by splitting into two segments

31/94 Cohen-Sutherland Algorithm Every end point is assigned to a four-digit binary value, i.e. Region code Each bit position indicates whether the point is inside or outside of a specific window edge bit 4bit 3bit 2bit 1 leftrightbottomtop

32/94 Cohen-Sutherland Algorithm

33/94 Cohen-Sutherland Algorithm Classify p 0, p 1 using region codes c 0, c 1 If, trivially reject If, trivially accept Otherwise reduce to trivial cases by splitting into two segments

34/94 Cohen-Sutherland Algorithm Classify p 0, p 1 using region codes c 0, c 1 If, trivially reject If, trivially accept Otherwise reduce to trivial cases by splitting into two segments

35/94 Cohen-Sutherland Algorithm Classify p 0, p 1 using region codes c 0, c 1 If, trivially reject If, trivially accept Otherwise reduce to trivial cases by splitting into two segments Line is outside the window! reject

36/94 Cohen-Sutherland Algorithm Classify p 0, p 1 using region codes c 0, c 1 If, trivially reject If, trivially accept Otherwise reduce to trivial cases by splitting into two segments Line is inside the window! draw

37/94 Cohen-Sutherland Algorithm Classify p 0, p 1 using region codes c 0, c 1 If, trivially reject If, trivially accept Otherwise reduce to trivial cases by splitting into two segments

38/94 Cohen-Sutherland Algorithm

39/94 Cohen-Sutherland Algorithm

40/94 Cohen-Sutherland Algorithm

41/94 Cohen-Sutherland Algorithm

42/94 Cohen-Sutherland Algorithm

43/94 Cohen-Sutherland Algorithm

44/94 Cohen-Sutherland Algorithm

45/94 Cohen-Sutherland Algorithm

46/94 Cohen-Sutherland Algorithm

47/94 Cohen-Sutherland Algorithm

48/94 Cohen-Sutherland Algorithm

49/94 Cohen-Sutherland Algorithm

50/94 Cohen-Sutherland Algorithm

51/94 Cohen-Sutherland Algorithm

52/94 Cohen-Sutherland Algorithm

53/94 Liang-Barsky Algorithm Uses parametric form of line for clipping Lines are oriented Classify lines as moving inside to out or outside to in Don’t find actual intersection points Find parameter values on line to draw

54/94 Liang-Barsky Algorithm Initialize interval to [t min, t max ]=[0,1] For each boundary  Find parametric intersection t with boundary  If moving in to out, t max = min(t max, t)  else t min = max(t min, t)  If t min >t max, reject line

55/94 Intersecting Two Parametric Lines

56/94 Intersecting Two Parametric Lines

57/94 Intersecting Two Parametric Lines

58/94 Intersecting Two Parametric Lines

59/94 Intersecting Two Parametric Lines

60/94 Intersecting Two Parametric Lines Substitute t or s back into equation to find intersection

61/94 Liang-Barsky: Classifying Lines

62/94 Liang-Barsky: Classifying Lines

63/94 Liang-Barsky: Classifying Lines

64/94 Liang-Barsky: Classifying Lines

65/94 Liang-Barsky: Classifying Lines

66/94 Liang-Barsky: Classifying Lines

67/94 Liang-Barsky: Classifying Lines

68/94 Liang-Barsky: Classifying Lines

69/94 Liang-Barsky Algorithm

70/94 Liang-Barsky Algorithm

71/94 Liang-Barsky Algorithm

72/94 Liang-Barsky Algorithm

73/94 Liang-Barsky Algorithm

74/94 Liang-Barsky Algorithm

75/94 Liang-Barsky Algorithm

76/94 Liang-Barsky Algorithm

77/94 Liang-Barsky Algorithm

78/94 Liang-Barsky Algorithm

79/94 Liang-Barsky Algorithm

80/94 Liang-Barsky Algorithm

81/94 Liang-Barsky Algorithm

82/94 Liang-Barsky Algorithm

83/94 Liang-Barsky Algorithm

84/94 Liang-Barsky Algorithm

85/94 Liang-Barsky Algorithm

86/94 Liang-Barsky Algorithm

87/94 Liang-Barsky Algorithm

88/94 Liang-Barsky Algorithm

89/94 Liang-Barsky Algorithm

90/94 Liang-Barsky Algorithm

91/94 Liang-Barsky Algorithm

92/94 Liang-Barsky Algorithm

93/94 Comparison Cohen-Sutherland  Repeated clipping is expensive  Best used when trivial acceptance and rejection is possible for most lines Liang-Barsky  Computation of t-intersections is cheap (only one division)  Computation of (x,y) clip points is only done once  Algorithm doesn’t consider trivial accepts/rejects  Best when many lines must be clipped

94/94 Line Clipping – Considerations Just clipping end-points does not produce the correct results inside the window Must also update sum in midpoint algorithm Clipping against non-rectangular polygons is also possible but seldom used