159.235Graphics1 159.235 Graphics & Graphical Programming Lecture 23 - Viewing & Clipping.

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

Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 7 Scanline algorithm and polygon clipping Taku Komura.
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 , )
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.
CS 551 / 645: Introductory Computer Graphics Clipping Lines and Polygons.
Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.
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)
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.
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 Viewing.
Clipping CSE 403 Computer Graphics Cohen Sutherland Algorithm (Line)
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.
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 Computer Graphics Chapter 4 2D Viewing Algorithms.
Visibility culling – Clipping. The visibility problem What polygons are visible? There are few visible polygons. –Avoid redundant processing Three classes.
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.
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)
Windows, Viewports, and Clipping
Implementation of a Renderer Consider Programs are processd by the system line & polygon, outside the view volume Efficiently Understanding of the implementation.
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
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.
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.
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphics Clipping.
Introduction to Computer Graphics with WebGL
Transformations contd.
CS 551 / 645: Introductory Computer Graphics
Computer Graphics Shading in OpenGL
Concepts, Algorithms for line clipping
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Concepts, algorithms for clipping
Implementation I Ed Angel
Graphics Pipeline Clipping
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
WINDOWING AND 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
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
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.
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Clipping Clipping Sutherland-Hodgman Clipping
Implementation I Ed Angel Professor Emeritus of Computer Science
COMPUTER GRAPHICS Clipping
Presentation transcript:

Graphics Graphics & Graphical Programming Lecture 23 - Viewing & Clipping

Graphics2 Viewing & Clipping - Outline Viewing in 2D Clipping in 2D Cohen-Sutherland Algorithm Cyrus & Beck Algorithm Clipping Polygons Sutherland-Hodgman Algorithm

Graphics3 Viewing in 2 Dimensions In 2D, a ‘world’ consists of an infinite plane, defined in ‘world’ coordinates, i.e metres, angstroms or other units appropriate to the model We normally pick an area of the 2D plane to view, referred to as the viewing ‘window’. On our display device, need to allocate an area for display, referred to as the ‘viewport’ in device specific coordinates. –We “Clip” objects outside of window. –We “Translate” coordinates to fit the viewport. –We “Scale” to the device coordinates.

Graphics4 Viewing in 2D - Viewport Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.

Graphics5 Clipping in 2D Need to clip primitives (eg lines) against the sides of the viewing window –e.g lines or polygons –We only see what is inside the window

Graphics6 Trivial Clipping Acceptance If all a line’s vertices lie inside box we “accept” it

Graphics7 Trivial Vertex Rejection All line vertices lie outside and on same side  reject.

Graphics8 This is an efficient method of accepting or rejecting lines that do not intersect the window edges. Assign a binary 4 bit code to each vertex : –First bit : above top of window, y > ymax –Second bit : below bottom, y < ymin –Third bit : to right of right edge, x > xmax –Fourth bit : to left of left edge, x < xmin –4-bit code called: Outcode Cohen-Sutherland Clipping Algorithm

Graphics9 Cohen-Sutherland 2D Outcodes

Graphics10 Cohen-Sutherland Algorithm Both endpoint codes 0000, trivial acceptance, else: Do logical AND of Outcodes (reject if non-zero)

Graphics11 Cohen-Sutherland Algorithm Logical AND between codes for 2 endpoints, Reject line if non-zero – trivial rejection. 0001

Graphics12 Line Intersection. Now need to intersect line segments with edges of clip rectangle. Select any clip edge, trivial line-splitting, feed two new lines back into algorithm - known as re-entrant Alternatively express line in parametric form to handle vertical lines. ( ie x=x(t), y=y(t), parameter t ) –Substitute for x or y. –Solve for t. –Need to perform 4 intersection checks for each line.

Graphics13 Cyrus & Beck Algorithm Treat line in parametric form. Note line will cross all clip boundaries somewhere :

Graphics14 Cyrus & Beck Algorithm Treat line in parametric form. Note line will cross all clip boundaries somewhere : –Find all intersections, test afterwards to determine if they are on the clip rectangle. –Define a point on the clipping plane and its normal. –Notice the dot product between a vector from this point and the intersection is zero.

Graphics15 Cyrus & Beck algorithm Edge E j NjNj P0P0 P1P1 P EJ

Graphics16 Cyrus & Beck algorithm Sign of denominator is important. Must  0 ( ignore parallel lines ). Parametric form implies direction. Denominator < 0  point entering clip region. Denominator > 0  point leaving clip region.

Graphics17 Cyrus & Beck algorithm Denominator < 0  point entering clip region, classify as PE Denominator > 0  point leaving clip region, classify as PL Edge E j NjNj  D

Graphics18 Cyrus & Beck Algorithm Sort PE’s and PL’s according to t. PE PL PE t t Draw from a PE  PL pair. PL < PE  no intersection

Graphics19 Clipping Polygons Clip polygons by clipping successively against 4 sides.

Graphics20 Clipping Polygons Clip polygons by clipping successively against all 4 sides Can implement as pipelined algorithm (ie special hardware can do the work) Recursively test each edge. –Form new edge with next vertex –Call with new edge

Graphics21 Sutherland-Hodgman Clipping Algorithm Output Vertex First Output Four cases of polygon clipping: InsideOutsideInsideOutsideInsideOutsideInsideOutside Case 3 No output. Case 1Case 2. Output Intersection Case 4 Second Output

Graphics22 Loop round vertices, test each against all 4 clipping planes in sequence Call algorithm again with new edge formed by next vertex -re-entrant No storage requirement between stages –Easy to implement in hardware Sutherland-Hodgman Algorithm

Graphics23 Java 2D Clipping Can use any Shape as clipping boundary Graphics2D has: –clip(Shape sh ); –Shape sh = getClip(); –setClip(Shape sh ); See the API :-) The clipping shape can be any of the Shape types supported as well as the more normal Rectangle. In other circumstances you may need to implement your own clipping In 3D we need to clip to a volume - not just a 2D shape

Graphics24 Viewing & Clipping - Summary Window and ViewPort Clipping cuts out what we do not “see” Also reduces unnecessary computation Can be done at various levels Java 2D system does a lot of the clipping for us if we use that rendering pipeline Acknowledgement: Thanks to Eric McKenzie, Edinburgh, from whose Graphics Course some of these slides were based.