Line Clipping Algorithms. A Cases for Clipping Lines E B H C G J I clip rectangle 2Prepared by Narendra V G CSE MIT.

Slides:



Advertisements
Similar presentations
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Clipping Concepts, Algorithms for line clipping 1 of 16 Clipping - 10/16/12.
Advertisements

Rezanje črt in poligonov. World window & viewport window viewport screen window world window.
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.
Computer Graphics Lecture 8 Arbitrary Viewing II: More Projection, Clipping and Mathematics of 3D Viewing.
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.
CS 551 / 645: Introductory Computer Graphics Clipping Lines and Polygons.
Chi-Cheng Lin, Winona State University CS430 Computer Graphics Cohen-Sutherland Line Clipping Algorithm.
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)
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:
Clipping Lines Lecture 7 Wed, Sep 10, The Graphics Pipeline From time to time we will discuss the graphics pipeline. The graphics pipeline is the.
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,
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
Implementation Dr. Amy Zhang. Reading 2  Hill, Chapters  Hill, Chapter 10.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 Computer Graphics Chapter 4 2D Viewing Algorithms.
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.
CS 325 Introduction to Computer Graphics 03 / 03 / 2010 Instructor: Michael Eckmann.
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.
Clipping: Clipping is a process of dividing an object into visible and invisible positions and displaying the visible portion and discarding the invisible.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
Clipping CSCI 440 textbook section Starter Question How do we clip these lines? X=-5 Y=-5 Y=5 X=5 [0,0] [3,3] [7,-3] [0,-3] formula from wikipedia.
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)
Windows, Viewports, and Clipping
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.
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphics Clipping.
Introduction to Computer Graphics with WebGL
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
CS 551 / 645: Introductory Computer Graphics
Computer Graphics Shading in OpenGL
Concepts, Algorithms for line clipping
3D rezanje 3D Clipping view frustrum clipping planes clipped.
Concepts, algorithms for clipping
Implementation I Ed Angel
Graphics Pipeline Clipping
Computer Graphics : Viewing In 2D
Clipping Computer Graphics Cohen Sutherland Algorithm (Line)
Lecture 13 Clipping & Scan Conversion
Segment Clipping Simple algorithm. For each segment compute the intersection with the four sides of the rectangle, and then determine which sub-segment.
3D rezanje 3D Clipping view frustrum clipping planes clipped.
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Clipping Clipping Sutherland-Hodgman Clipping
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Implementation I Ed Angel Professor Emeritus of Computer Science
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Presentation transcript:

Line Clipping Algorithms

A Cases for Clipping Lines E B H C G J I clip rectangle 2Prepared by Narendra V G CSE MIT

A B Cases for Clipping Lines C 3Prepared by Narendra V G CSE MIT

Clipping Targets Points Lines Polygons Text Other Objects 4Prepared by Narendra V G CSE MIT

Clipping One of oldest problems in graphics We will study problem of Clip Line against an axis-oriented rectangular window Many variations of this problem 5Prepared by Narendra V G CSE MIT

General Problem Clip one object wrt another object Requires intersection calculations Interesting problem Floating point causes difficulties Relates to many other problems Graphics does things fast…. 6Prepared by Narendra V G CSE MIT

Cohen-Sutherland Line Clipping

Region Outcodes Prepared by Narendra V G CSE MIT

Cohen-Sutherland Clipping: “Outcodes” Prepared by Narendra V G CSE MIT

Look at Sign Bits ( neg  1) Bit 1 Bit 2 Bit 3 Bit 4 10Prepared by Narendra V G CSE MIT

Need to Classify Endpoint Look at What does it tell us? “trivial reject” Both ends in a row or column outside 11Prepared by Narendra V G CSE MIT

Region Outcodes Bit above window Bit below window Bit right of window Bit left of window 12Prepared by Narendra V G CSE MIT

Classify Endpoint Endpoints may not be in window Clip an end for which Test again. May need more. 13Prepared by Narendra V G CSE MIT

Cohen-Sutherland Clipping: Trivial Acceptance: O(P0) = O(P1) = P0 P1 14Prepared by Narendra V G CSE MIT

Cohen-Sutherland Clipping: Trivial Rejection: O(P0) & O(P1)  P0 P1 P0 15Prepared by Narendra V G CSE MIT

Cohen-Sutherland Clipping: O(P0) =0, O(P1)  P0 P1 P0 16Prepared by Narendra V G CSE MIT

Cohen-Sutherland Clipping: O(P0) & O(P1)  P0 P1 17Prepared by Narendra V G CSE MIT

Cohen-Sutherland Clipping: The Algorithm Compute the outcodes for the two vertices Test for trivial acceptance or rejection Select a vertex for which outcode is not zero –There will always be one Select the first nonzero bit in the outcode to define the boundary against which the line segment will be clipped Compute the intersection and replace the vertex with the intersection point Compute the outcode for the new point and iterate 18Prepared by Narendra V G CSE MIT

I H G F E Cohen-Sutherland Line Clipping D C B A Prepared by Narendra V G CSE MIT

I H G F E D C B A Cohen-Sutherland Line Clipping 20Prepared by Narendra V G CSE MIT

Initial Outcode Calculations OC(D)=1000; OC(A)=0001 OC(E)=0100; OC(I)= Prepared by Narendra V G CSE MIT

Clip and Continue Clip against the top boundary Calculate B. Keep AB Calculate H. Keep EH 22Prepared by Narendra V G CSE MIT

H G F E Cohen-Sutherland Line Clipping B A 23Prepared by Narendra V G CSE MIT

Clip and Continue Clip against the bottom boundary Now test and reject AB because OC ( A )=0001 and OC ( B )=0001; Reject AB on outcode basis 24Prepared by Narendra V G CSE MIT

Outcode Calculations OC ( H )= 0010 ; OC ( E )= 0100 Since product is 0, process HE to get FH 25Prepared by Narendra V G CSE MIT

H G F Cohen-Sutherland Line Clipping Prepared by Narendra V G CSE MIT

Outcode Calculations OC ( F )= 0000 ; OC ( H )= 0010 Since product is 0, process HF to get GF 27Prepared by Narendra V G CSE MIT

Clip and Continue Clip against the right boundary Get GF Done 28Prepared by Narendra V G CSE MIT

G F Cohen-Sutherland Line Clipping 29Prepared by Narendra V G CSE MIT

Process Ends Do not have to do x min Normally it would continue to last stage 30Prepared by Narendra V G CSE MIT

When is this algorithm good? If it trivally rejects(accepts) most cases Good if window large wrt to data Good if window small wrt to data Eg, it works well in extreme cases with mostly trivial decisions 31Prepared by Narendra V G CSE MIT

08/29/13 5/14/2015Prepared by Narendra V G CSE MIT32

08/29/13 5/14/2015Prepared by Narendra V G CSE MIT33

08/29/13 5/14/2015Prepared by Narendra V G CSE MIT34

08/29/13 5/14/2015Prepared by Narendra V G CSE MIT35

Cohen-Sutherland Clipping: Advantages/Extension Easily extended to 3 dimensions by adding two bits to the outcode for the z axis. Calculations then reduce to intersection of line with plane Algorithm most efficient when most segments can either be trivially accepted or trivially rejected 36Prepared by Narendra V G CSE MIT