Computer Graphics 4: Viewing In 2D

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

Clipping Covers chapter 10 of Computer Graphics and Virtual Environments (Slater, Steed and Chrysanthou) . See ©Yiorgos Chrysanthou.
9.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 9 – Clipping.
CGPage: 1 We can define a window as a rectangular region of the world coordinate space, and the viewport as a rectangular region of the device coordinate.
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.
Construction of a regular pentagon Dr Andrew French Const. Pent. p1 of 10. A.French 2012.
Computer Graphics CLIPPING.
Objectives Define Clipping Various clipping methods. Line clipping methods.
Java ThreadsGraphics Programming Graphics Programming: Windows, Viewports & Clipping.
Course Website: Computer Graphics 4: Viewing In 2D.
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.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Two Dimensional Viewing Dr. Eng. Farag Elnagahy
Course Website: Computer Graphics 9: Clipping In 3D.
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.
1 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
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,
EEL Introduction to Computer Graphics
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
2D Viewing.
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.
Clipping.
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.
Computer Graphics Shading in OpenGL
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Concepts, algorithms for clipping
3D Clipping.
Implementation I Ed Angel
Graphics Pipeline Clipping
Computer Graphics 9: Clipping In 3D
Chapter 7 2D Clipping.
WINDOWING AND CLIPPING
o عَلَّمَهُ الْبَيَانَ
Computer Graphics : Viewing In 2D
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
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
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Implementation I Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Computer Graphics 4: Viewing In 2D

Contents *Windowing Concepts *Clipping Point Clipping Line Clipping -Cohen-Sutherland Clipping Algorithm *Area Clipping Sutherland-Hodgman Area Clipping Algorithm

Windowing I World Coordinates A scene is made up of a collection of objects specified in world coordinates. Next World Coordinates

Windowing II Window wymax wymin World Coordinates wxmin wxmax When we display a scene only those objects within a particular window are displayed. Window wymax wymin Next World Coordinates wxmin wxmax

Windowing III Window wymax wymin World Coordinates wxmin wxmax Because drawing things to a display takes time we clip everything outside the window. Window wymax wymin BACK World Coordinates wxmin wxmax

Clipping Window wymax wymin wxmin wxmax For the image below consider which lines and points should be kept and which ones should be clipped. P4 Window P2 wymax P6 P3 P1 P7 P5 P9 P8 wymin P10 BACK wxmin wxmax

Points Within the Window are Not Clipped Point Clipping Easy - a point (x,y) is not clipped if: wxmin ≤ x ≤ wxmax AND wymin ≤ y ≤ wymax otherwise it is clipped. P4 Clipped Clipped Window P2 wymax Clipped P5 P1 P7 Points Within the Window are Not Clipped P9 P8 wymin Clipped P10 BACK wxmin wxmax

Line Clipping Situation Solution Example Harder - examine the end-points of each line to see if they are in the window or not. Situation Solution Example Both end-points inside the window Don’t clip One end-point inside the window, one outside Must clip Both end-points outside the window Don’t know! BACK

Cohen-Sutherland Clipping Algorithm -An efficient line clipping algorithm. -The key advantage of the algorithm is that it vastly reduces the number of line intersections that must be calculated.

Cohen-Sutherland: World Division World space is divided into regions based on the window boundaries Each region has a unique four bit region code. Region codes indicate the position of the regions with respect to the window. 1001 1000 1010 0001 0000 Window 0010 0101 0100 0110 above below right left 3 2 1 Region Code Legend

Cohen-Sutherland: Labelling Every end-point is labelled with the appropriate region code. wymax wymin wxmin wxmax Window P3 [0001] P6 [0000] P5 [0000] P7 [0001] P10 [0100] P9 [0000] P4 [1000] P8 [0010] P12 [0010] P11 [1010] P13 [0101] P14 [0110]

Cohen-Sutherland: Lines In The Window Lines completely contained within the window boundaries have region code [0000] for both end-points so are not clipped. wymax wymin wxmin wxmax Window P3 [0001] P6 [0000] P5 [0000] P7 [0001] P10 [0100] P9 [0000] P4 [1000] P8 [0010] P12 [0010] P11 [1010] P13 [0101] P14 [0110]

Cohen-Sutherland: Lines Outside The Window Any lines with a common set bit in the region codes of both end-points can be clipped. The AND operation can efficiently check this wymax wymin wxmin wxmax Window P3 [0001] P6 [0000] P5 [0000] P7 [0001] P10 [0100] P9 [0000] P4 [1000] P8 [0010] P12 [0010] P11 [1010] P13 [0101] P14 [0110]

Cohen-Sutherland: Other Lines Lines that cannot be identified as completely inside or outside the window may or may not cross the window interior These lines are processed as follows: Compare an end-point outside the window to a boundary (choose any order in which to consider boundaries e.g. left, right, bottom, top) and determine how much can be discarded If the remainder of the line is entirely inside or outside the window, retain it or clip it respectively.

Cohen-Sutherland: Other Lines (cont…) Otherwise, compare the remainder of the line against the other window boundaries. Continue until the line is either discarded or a segment inside the window is found. We can use the region codes to determine which window boundaries should be considered for intersection. To check if a line crosses a particular boundary we compare the appropriate bits in the region codes of its end-points If one of these is a 1 and the other is a 0 then the line crosses the boundary BACK

Area Clipping Similarly to lines, areas must be clipped to a window boundary. Consideration must be taken as to which portions of the area must be clipped. BACK

Sutherland-Hodgman Area Clipping Algorithm A technique for clipping areas developed by Sutherland & HodgmanPut simply the polygon is clipped by comparing it against each boundary in turn. Original Area Clip Left Clip Right Clip Top Clip Bottom

Sutherland-Hodgman Area Clipping Algorithm (cont…) To clip an area against an individual boundary: Consider each vertex in turn against the boundary Vertices inside the boundary are saved for clipping against the next boundary Vertices outside the boundary are clipped If we proceed from a point inside the boundary to one outside, the intersection of the line with the boundary is saved If we cross from the outside to the inside intersection point and the vertex are saved. BACK

Thanks !!!