Computer Graphics Clipping Cohen Sutherland Algorithm (Line) Cyrus-Back Algorithm (Line) Sutherland-Hodgeman Algorithm (Polygon) Cohen Sutherland Algorithm.

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.
Java ThreadsGraphics Programming Graphics Programming: Windows, Viewports & Clipping.
CS 551 / 645: Introductory Computer Graphics Clipping Lines and Polygons.
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,
2D Viewing and Projection
2 D viewing Prepared by Elizabeth Isaac DCS, RSET.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
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 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.
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.
Visibility culling – Clipping. The visibility problem What polygons are visible? There are few visible polygons. –Avoid redundant processing Three classes.
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.
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.
Clipping Computer Graphics Cohen Sutherland Algorithm (Line)
Windows, Viewports, and Clipping
Unit – IV 2D Viewing. 2 of 30 Contents Windowing Concepts The viewing pipeline viewing coordinate reference frame, window to view-port coordinate transformation,
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 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 Graphic 2 D Viewing.
Computer Graphics Clipping.
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
Computer Graphics Shading in OpenGL
Concepts, Algorithms for line clipping
Concepts, algorithms for clipping
Implementation I Ed Angel
Graphics Pipeline Clipping
WINDOWING AND CLIPPING
Computer Graphics : Viewing In 2D
Clipping Computer Graphics Cohen Sutherland Algorithm (Line)
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
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.
Clipping Clipping Sutherland-Hodgman Clipping
Clipping University of British Columbia CPSC 314 Computer Graphics
Implementation I Ed Angel Professor Emeritus of Computer Science
COMPUTER GRAPHICS Clipping
Presentation transcript:

Computer Graphics Clipping Cohen Sutherland Algorithm (Line) Cyrus-Back Algorithm (Line) Sutherland-Hodgeman Algorithm (Polygon) Cohen Sutherland Algorithm (3d)

Clipping-When we want to study the picture but not whole picture, study some part, enlarge the part make study(X-ray) Selecting and enlarging the part known-Windowing, We select the portion of image and making visible and invisible-Clipping(cutting of the line which is outside View port) Image in object space Image in View space Transformation is required (Translate and scale) Translate the origin and Scale the object and translate it back to original

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

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

(Wx-Wxmin)/(Wxmax-Wxmin) =(Vx-Vxmin)/(Vxmax-Vxmin) (Wy-Wymin)/(Wymax-Wymin) =(Vy-Vymin)/(Vymax-Vymin) Viewing Transformation (N) V=N * W Where N=Tv * S * T-v Aspect ratio Aw=(Wxmax-Wxmin)/(Wymax-Wymin) Av=(Vxmax-Vxmin)/(Vymax-Vymin)

Cases for clipping lines Line Clipping

Cases for clipping lines Line Clipping

Cases for clipping lines Line Clipping

Cases for clipping lines Line Clipping

Cases for clipping lines Line Clipping

Cases for clipping lines Line Clipping

Line Clipping-Midpoint subdivision - Cohen Sutherland Algo Midpoint- Check the line If it is entirely inside It is entirely outside (discard) It is partially inside and partially outside then Find mid point of two endpoints then divide line into two line segement and check both segments and continue

Algo for Midpoint 1- Check line Completely outside the window Completely inside the window Partially inside window (Line intersect boundary, divide it from mid point) 2-check again for both segemnts 3- Repeat step-1 until whole part of line inside the window

Clipping Lines by Solving Simultaneous Equations Line Clipping

The Cohen-Sutherland Line-Clipping Algorithm performs initial tests on a line to determine whether intersection calculations can be avoided. 1. First, end-point pairs are checked for Trivial Acceptance. 2. If the line cannot be trivially accepted, region checks are done for Trivial Rejection. 3. 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

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

Algo 1-Compute the codes for the Two end points 2-Enter in loop, check if both outcodes are zero(0000 and 0000) put line in display file for display and exit loop, return 3-if both outcodes are not zero then take logical AND of both codes, check result for nonzero if so reject line exit loop, return 4-if result is zero then subdivide the line from intersection point of line and clipping boundary and repeat step 2,3,4

An Example Cohen-Sutherland Algorithm

An Example Cohen-Sutherland Algorithm

An Example Cohen-Sutherland Algorithm

An Example Cohen-Sutherland Algorithm

Example Polygon Clipping

Example

Example

Sutherland-Hodgeman Algo. The Clipped Polygon

Clipping of the polygon -  Clip Left --  Clip right --  Clip bottom ---  Clip top ---  View transformation Consider Any Edge (P1P2) 1.If both p1,p2 are left to edge, p2 is placed vertex output list of clipped poly 2. If p1,p2 are right to edge discard 3. If p1,p2 cross edge and find intersection point (I) if p1 is left to edge then I will be in output list of vertex of clipped poly if p1 is right then both p1 and I in output list

Determination of point if is left right to line AB is line segement(x1,y1 and x2,y2) determine point p (x,y)is left or right to AB Find cross product of vectors AB and AP then resulted vector has direction vector k then point p is left to AB If –k the point p is right to AB AP=(x-x1) *I +(y-y1) * J AB=(x2-x1) *I +(y2-y1) * J AB X AP=[(x2-x1) *(y-y1)-(y2-y1)*(y-y1)]*k d=(x2-x1) *(y-y1)-(y2-y1)*(y-y1) If d=+ then p is left to AB If d=-Ve then p is right to AB

Case 1 4 Cases of Polygon Clipping Case 2 Case 3 Case 4

Algorithm

3D Clipping Both the Cohen-Sutherland and Cyrus-Beck clipping algorithm readily extend to 3D. For Cohen-Sutherland algorithm use two extra-bit in outcode for incorporating z z max regions

Thank You