CS U540 Computer Graphics Prof. Harriet Fell Spring 2007

Slides:



Advertisements
Similar presentations
9.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 9 – Clipping.
Advertisements

CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Clipping Concepts, Algorithms for line clipping 1 of 16 Clipping - 10/16/12.
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 , )
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.
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)
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.
Line Clipping Algorithms. A Cases for Clipping Lines E B H C G J I clip rectangle 2Prepared by Narendra V G CSE MIT.
Clipping CSE 403 Computer Graphics Cohen Sutherland Algorithm (Line)
CGPage: 1 東吳資訊科學 江清水 The process of clipping decides which part, if any, of a primitive lies inside the window. The algorithms used for line clipping can.
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.
1 Computer Graphics Chapter 4 2D Viewing Algorithms.
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
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.
Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.
2-Dimension Viewing and Clipping
College of Computer and Information Science, Northeastern UniversitySeptember 7, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2007.
Windowing and clipping
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.
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)
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.
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.
Clipping. Before clipping… After clipping… Point Clipping Display P = (x, y) if xw min
CENG 538 Advanced Graphics and UIs
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphic 2 D Viewing.
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
Basic Raster Graphics Algorithms for Drawing 2D Primitives
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Concepts, algorithms for clipping
3D Clipping.
CS5310 Graduate Computer Graphics
Implementation I Ed Angel
Graphics Pipeline Clipping
Prof. Harriet Fell Spring 2007 Lecture 9 – January 29, 2007
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
Joshua Barczak CMSC 435 UMBC
Two Dimensional Viewing and Clipping.
Segment Clipping Simple algorithm. For each segment compute the intersection with the four sides of the rectangle, and then determine which sub-segment.
Basic Raster Graphics Algorithms for Drawing 2D Primitives
Clipping Clipping Sutherland-Hodgman Clipping
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Clipping University of British Columbia CPSC 314 Computer Graphics
Implementation I Ed Angel Professor Emeritus of Computer Science
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
COMPUTER GRAPHICS Clipping
Presentation transcript:

CS U540 Computer Graphics Prof. Harriet Fell Spring 2007 Lectures 16 – February 11, 2009 17 – February 12, 2009 18 – February 16, 2009 February 28, 2019

Clipping Lines G D C F A F’ G’ E B K H’ J H

Intersections We know how to find the intersections of a line segment P + t(Q-P) with the 4 boundaries x = xmin x = xmax y = ymin y = ymax Q P February 28, 2019

Cohen-Sutherland Clipping Assign a 4 bit outcode to each endpoint. 0000 1000 1100 0010 above left below right 0100 0110 1001 0001 0011 //above left below right int outcode(x,y,xmin,xmax,ymin,ymax) { int code=0; if(x > xmax) code |= 1; //right if(y < ymin) code |= 2; //below if(x < xmin) code |= 4; //left if(y > ymax) code |= 8; //above return(code); } February 28, 2019

Cohen-Sutherland Clipping Identify lines that are trivially accepted or trivially rejected. 0000 1000 1100 0010 above left below right 0100 0110 1001 0001 0011 if(outcode(P)|outcode(Q)==0) accept else if(outcode(P)&outcode(Q))!=0) reject else test further February 28, 2019

Cohen-Sutherland continued Clip against one boundary at a time, top, left, bottom, right. Check for trivial accept or reject. If a line segment PQ falls into the “test further” category then if (outcode(P) & 1000  0) replace P with PQ intersect y = top else if (outcode(Q) & 1000  0) replace Q with PQ intersect y = top go on to next boundary February 28, 2019

G G’ G’’ ACCEPT H’ H

Cohen-Sutherland Applet By Patrick Min, CS Department, Princeton University February 28, 2019

Liang-Barsky Clipping Clip window interior is defined by: xleft  x  xright ybottom  y  ytop February 28, 2019

Liang-Barsky continued V1 = (x1, y1) x = x0 + tx x = x1 - x0 y = y0 + ty y = y1 - y0 t = 0 at V0 t = 1 at V1 V0 = (x0, y0) February 28, 2019

Liang-Barsky continued Put the parametric equations into the inequalities: xleft  x0 + tx  xright ybottom  y0 + ty  ytop -tx  x0 - xleft tx  xright - x0 -ty  y0 - ybottom ty  ytop - y0 These describe the interior of the clip window in terms of t. February 28, 2019

Liang-Barsky continued -tx  x0 - xleft tx  xright - x0 -ty  y0 - ybottom ty  ytop - y0 These are all of the form tp  q For each boundary, we decide whether to accept, reject, or which point to change depending on the sign of p and the value of t at the intersection of the line with the boundary. February 28, 2019

x = xleft p = - x V1 t  t (-x)  (x0 – xleft) t = (x0 – xleft)/(x0 – x1 ) is between 0 and 1. x = x1 – x0 > 0 so p < 0  replace V0 V0 V1 t = (x0 – xleft)/(x0 – x1 ) is between 0 and 1. x = x1 – x0 < 0 so p > 0  replace V1  t V0

x = tleft p = - x V1 p < 0 so might replace V0 but t = (x0 – xleft)/(x0 – x1 ) < 0 so no change. V0 t  V1 V0 p > 0 t > 1 V1 V0 t  p < 0 so might replace V0 but t = (x0 – xleft)/(x0 – x1 ) > 1 so reject.  t V0 V1 p > 0 so might replace V1 but t = (x0 – xleft)/(x0 – x1 ) < 0 so reject.

Liang-Barsky Rules 0 < t < 1, p < 0 replace V0 t < 0, p < 0 no change t < 0, p > 0 reject t > 1, p > 0 no change t > 1, p < 0 reject February 28, 2019

Polygon Clipping February 28, 2019

Sutherland-Hodgeman Polygon Clipping Algorithm Clip one boundary at a time: left, top, right, bottom. Check each adjacent pair of vertices (P,Q), in order to make a new vertex list. If P is out and Q is in, add intersection point with boundary and Q. If P and Q are in, add Q. If P is in and Q is out, add the intersection point with boundary only. If P and Q are both out, add nothing. February 28, 2019

Sutherland-Hodgeman Clipping Example V1 New Vertex List V2 Clip Left V2 V3 L2 If P is out and Q is in, add intersection point with boundary and Q. If P is in and Q is out, add the intersection point with boundary only. V4 If P and Q are in, add Q. V6 L1 V5 L1 V5 L2 V3 V1 V4 February 28, 2019

Sutherland-Hodgeman Clipping Example V1 New Vertex List V2 Clip Left V2 Clip Top V3 L2 V4 V5 L1 L1 V5 L2 V3 V1 V4 February 28, 2019

Sutherland-Hodgeman Clipping Example V1 New Vertex List V2 Clip Top T2 T1 T1 V3 L2 If P is in and Q is out, add the intersection point with boundary only. If P is out and Q is in, add intersection point with boundary and Q. V4 If P and Q are both out, add nothing. If P and Q are in, add Q. V5 L1 L1 V5 L2 V3 T2 V4 February 28, 2019

Sutherland-Hodgeman Clipping Example New Vertex List Clip Right Clip Top T2 T1 T1 V3 L2 V4 V5 L1 L1 V5 L2 V3 T2 V4 February 28, 2019

Sutherland-Hodgeman Clipping Example New Vertex List Clip Right T2 T1 R1 R2 R1 L2 V4 V5 L1 L1 V5 L2 V3 T2 R2 T1 V4 February 28, 2019

Sutherland-Hodgeman Clipping Example New Vertex List T2 T1 R2 B1 R1 L2 B2 V5 L1 L1 V5 L2 T2 R2 T1 Clip Bottom B2 B1 R1 V4 February 28, 2019

Sutherland-Hodgeman Clipping Example New Vertex List T2 T1 R2 B1 R1 L2 B2 V5 L1 L1 V5 L2 T2 R2 T1 B2 B1 R1 February 28, 2019

Sutherland-Hodgeman Exercise 1 Vertex List initial after after after after left top right bottom A B C D A D B C February 28, 2019

Sutherland-Hodgeman Exercise 2 Vertex List initial after after after after left top right bottom H I I A A A B B B C C C D D D E E E F F F G G G H H I A G R1 I D R4 B F R3 E R2 H C February 28, 2019

Sutherland-Hodgeman Exercise 2 Vertex List initial after after after after left top right bottom H I I A A A R1 K B B B R2 B1 C C C D D D D D R3 B2 E E E R4 K F F F G R4 G G G H G H H I B3 I A B4 I A R1 A G R1 I D R4 B F B4 B3 B2 K R3 B1 E R2 H C February 28, 2019