Clipping Computer Graphics Cohen Sutherland Algorithm (Line)

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 , )
Introduction Abstract C-S clip V-window1 V-window2 Summary  Clipping is an basic operation of computer graphics  Classical line clipping algorithms 1)Cohen-sutherland.
Computer Graphics CLIPPING.
3D Clipping & Viewing process
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 551 / 645: Introductory Computer Graphics Clipping Lines and Polygons.
Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.
David Breen, William Regli and Maxim Peysakhov
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:
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.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
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 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.
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.
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.
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.
CSE Real Time Rendering Week 9. Post Geometry Shaders Courtesy: E. Angel and D. Shreiner – Interactive Computer Graphics 6E © Addison-Wesley 2012.
Windows, Viewports, and Clipping
EEL Introduction to Computer Graphics
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.
Clipping. Before clipping… After clipping… Point Clipping Display P = (x, y) if xw min
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphic 2 D Viewing.
Computer Graphics Clipping.
Transformations contd.
CS 551 / 645: Introductory Computer Graphics
Computer Graphics Shading in OpenGL
Concepts, Algorithms for line clipping
Concepts, algorithms for clipping
3D Clipping.
Implementation I Ed Angel
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 Lines Jinxiang Chai
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.
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
COMPUTER GRAPHICS Clipping
Presentation transcript:

Clipping Computer Graphics Cohen Sutherland Algorithm (Line) Cyrus-Back Algorithm (Line) Midpoint Subdivision Algorithm

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

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

Cases for clipping lines Line Clipping Cases for clipping lines

Cases for clipping lines Line Clipping Cases for clipping lines

Cases for clipping lines Line Clipping Cases for clipping lines

Cases for clipping lines Line Clipping Cases for clipping lines

Cases for clipping lines Line Clipping Cases for clipping lines

Cases for clipping lines Line Clipping Cases for clipping lines

Clipping Lines by Solving Simultaneous Equations Line Clipping Clipping Lines by Solving Simultaneous Equations

Cohen-Sutherland Algorithm The Cohen-Sutherland Line-Clipping Algorithm performs initial tests on a line to determine whether intersection calculations can be avoided. First, end-point pairs are checked for Trivial Acceptance. If the line cannot be trivially accepted, region checks are done for Trivial Rejection. If the line segment can be neither trivially accepted or rejected, it is divided into two segments at a clip edge, so that one segment can be trivially rejected. These three steps are performed iteratively until what remains can be trivially accepted or rejected.

Cohen-Sutherland Algorithm Region outcodes

The rightmost bit is the first bit The rightmost bit is the first bit. The bits are set to 1 based on the following scheme. 1) First bit Set- If the end point is to the left of the window. 2) Second bit Set- If the end point is to the right of the window. 3) Third bit Set- If the end point is to the below the window. 4) Fourth bit Set- If the end point is to the above the window. Otherwise the bit is set to Zero.

The intersection with the window edges are given by Left XL Y=m(XL-X1)+Y1 Right XR Y=m(XR-X1)+Y1 Top YT X=X1+1/m(YT-Y1) Bottom YB X=X1+1/m(YB-Y1)

Cohen-Sutherland Algorithm A line segment can be trivially accepted if the outcodes of both the endpoints are zero. A line segment can be trivially rejected if the logical AND of the outcodes of the endpoints is not zero. A key property of the outcode is that bits that are set in nonzero outcode correspond to edges crossed.

Cohen-Sutherland Algorithm An Example

Cohen-Sutherland Algorithm An Example

Cohen-Sutherland Algorithm An Example

Cohen-Sutherland Algorithm An Example

Parametric Line-Clipping (1) This fundamentally different (from Cohen-Sutherland algorithm) and generally more efficient algorithm was originally published by Cyrus and Beck. (2) Liang and Barsky later independently developed a more efficient algorithm that is especially fast in the special cases of upright 2D and 3D clipping regions.They also introduced more efficient trivial rejection tests for general clip regions.

The Cyrus-Back Algorithm

The Cyrus-Back Algorithm

The Cyrus-Back Algorithm PE = Potentially Entering PL = Potentially Leaving

The Cyrus-Back Algorithm Precalculate Ni and PEi for each edge for (each line segment to be clipped) { if (P1 == P0) line is degenerated, so clip as a point; else { tE = 0; tL = 1; for (each candidate intersection with a clip edge) { if (Ni • D != 0) { /* Ignore edges parallel to line */ calculate t; use sign of Ni • D to categorize as PE or PL; if (PE) tE = max(tE , t); if (PL) tL = min(tL , t); } } if (tE > tL) return NULL; else return P(tE) and P(tL) as true clip intersection;

Mid Point Subdivision Algorithm The Cohen-Sutherland algorithm requires the calculation of the intersection of the line with window edge. This direct calculation can be avoided by performing a binary search for the intersection by always dividing the line at its mid point. This algorithm is implemented in hardware.

Mid Point Subdivision Algorithm Implementation in hardware is fast & efficient because a parallel architecture can be used and hardware addition & division by 2 are very fast. In hardware, division by 2 can be accomplished by shifting each bit to the right. The algorithm uses the line end point codes & associated test to immediately identify totally visible lines, & trivially invisible lines.

Mid Point Subdivision Algorithm Lines which can not be immediately identified using there test are subdivided into 2 equal parts. The test are then applied to each half until the intersection with the window edge is found or the length of the divided segment is infinitesimal i.e. 0 point. The visibility of the point is then determined. The result is to perform a logarithmic search for the intersection point.

Mid Point Subdivision Algorithm Pm2 Pm1 P2 P1 Pm2 Pm1 Pm2 P2

Thank You