2D Viewing and Projection

Slides:



Advertisements
Similar presentations
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.
Advertisements

Computer Graphics 4: Viewing In 2D
Rezanje črt in poligonov. World window & viewport window viewport screen window world window.
Computer Graphics CLIPPING.
Objectives Define Clipping Various clipping methods. Line clipping methods.
Java ThreadsGraphics Programming Graphics Programming: Windows, Viewports & Clipping.
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.
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.
Computer Graphics : Clipping
Computer Graphics Viewing.
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,
2 D viewing Prepared by Elizabeth Isaac DCS, RSET.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
X y (x,y) x - coordinate y - coordinate. How are coordinates helpful?
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 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Two Dimensional Viewing Dr. Eng. Farag Elnagahy
CS 376 Introduction to Computer Graphics 02 / 26 / 2007 Instructor: Michael Eckmann.
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.
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.
CS 325 Introduction to Computer Graphics 03 / 03 / 2010 Instructor: Michael Eckmann.
2-Dimension Viewing and Clipping
Windowing and clipping
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
Two-Dimensional Viewing
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.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 2D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
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,
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
EEL Introduction to Computer Graphics
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
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 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.
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.
Clipping.
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.
2D Viewing & Clipping 한신대 류승택
Concepts, algorithms for clipping
3D Clipping.
Graphics Pipeline Clipping
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
WINDOWING AND CLIPPING
o عَلَّمَهُ الْبَيَانَ
Computer Graphics : Viewing In 2D
WINDOWING AND CLIPPING
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.
COMPUTER GRAPHICS Clipping
Presentation transcript:

2D Viewing and Projection Dr. Aree Ali Mohammed Assistant Professor 2014-2015 3rd Stage aree.ali@univsul.edu.iq University of Sulaimani - School of Science - Computer Dept.

Windowing and Clipping The process of selecting and viewing the picture with different views is called windowing. The process which divides each element of the picture into its visible and invisible portions, allowing the invisible portion to be discarded is called clipping. Windowing and Clipping Window wymax wymin wxmin wxmax World Coordinates World Coordinates

Viewing Transformation I Picture stored in a computer  WCS (World Coordinate System) Picture displayed on a device  PDCS (Physical Device CS) Mapping from WCS to PDCS  Viewing Transformation Normalization Transformation  Device independent University of Sulaimani - School of Science - Computer Dept.

Viewing Transformation II 1. Normalization Transformation  Device independent An interpreter is used to convert the normalized device coordinates to the actual device coordinates. The transformation which maps the world coordinate to normalized device coordinate is called normalization transformation. It involves scaling of x and y, thus it is also referred to as scaling transformation University of Sulaimani - School of Science - Computer Dept.

Viewing Transformation III 2. Workstation Transformation Maps normalized device coordinates  physical device coordinates The viewing transformation is the combination of normalization transformation and workstation transformation. 00000000000000 Normalization Transformation NC Workstation Transformation WC DC 2D Viewing V=N.W University of Sulaimani - School of Science - Computer Dept.

Viewing Transformation IV Workstation Transformation WCS  infinite  finite  window Device display  finite  viewport The window defines what is to be viewed; the viewport defines where it is to be displays. University of Sulaimani - School of Science - Computer Dept.

Viewing Transformation V Workstation Transformation Steps

Viewing Transformation VI

Viewing Transformation VII Normalization Transformation NC DC WC Ex: Find the normalization transformation window to viewport, with window, lower left corner at (1,1) and upper right corner at (3,5) onto a viewpoint with lower left corner at (0,0) and upper right corner at (1/2,1/2). Sol:

University of Sulaimani - School of Science - Computer Dept. 2D Clipping 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 wxmin wxmax University of Sulaimani - School of Science - Computer Dept.

University of Sulaimani - School of Science - Computer Dept. 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 wxmin wxmax University of Sulaimani - School of Science - Computer Dept.

Line Clipping 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!

Line Clipping Algorithms (I) Sutherland and Cohen Subdivision Algorithm Reduce the number of intersections  speed up Use four digit (bit) code to indicate which of nine regions contain the end point of line. Called region code or outcodes. 1001 1000 1010 0001 0000 Window 0010 0101 0100 0110 4 3 2 1 above below right left Region Code Legend University of Sulaimani - School of Science - Computer Dept.

Line Clipping Algorithms (II) Ex: Consider the clipping window and the lines shown in figure. Find the region codes for each end point and identify whether the line is completely visible, partially visible or completely invisible. University of Sulaimani - School of Science - Computer Dept.

University of Sulaimani - School of Science - Computer Dept.

Calculating Line Intersections I Intersection points with the window boundaries are calculated using the line-equation parameters Consider a line with the end-points (x1, y1) and (x2, y2) The y-coordinate of an intersection with a vertical window boundary can be calculated using: y = y1 + m (xboundary - x1) where xboundary can be set to either wxmin or wxmax University of Sulaimani - School of Science - Computer Dept.

Calculating Line Intersections II The x-coordinate of an intersection with a horizontal window boundary can be calculated using: x = x1 + (yboundary - y1) / m where yboundary can be set to either wymin or wymax m is the slope of the line in question and can be calculated as m = (y2 - y1) / (x2 - x1) University of Sulaimani - School of Science - Computer Dept.

University of Sulaimani - School of Science - Computer Dept. 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 University of Sulaimani - School of Science - Computer Dept.

Sutherland-Hodgman Area Clipping Algorithm A technique for clipping areas developed by Sutherland & Hodgman Put simply the polygon is clipped by comparing it against each boundary in turn Clip Bottom Original Area Clip Left Clip Right Clip Top University of Sulaimani - School of Science - Computer Dept.

University of Sulaimani - School of Science - Computer Dept. 2D Polygon Clipping University of Sulaimani - School of Science - Computer Dept.

University of Sulaimani - School of Science - Computer Dept. Review Questions Write short note on viewing transformation. Distinguish between viewport and window. What do you mean by normalization transformation? Why it is needed? Derive the transformation matrix for 2D viewing transformation. What is point and line clipping? Explain the Sutherland and Cohen Subdivision Algorithm for line clipping. Use Sutherland and Cohen outcode Algorithm to clip two lines P1 (40,50) – P2 (75,45) and P3(70,20), P4(100,10) against a window A(50,10), B(80,10), C(80,40), D(50,40). Clip the line P1(-3/2,1/6) and P2(1/2,3/2) against window A(-1,-1), B(-1,1), C(1,1) and D(1,-1) using Sutherland and Cohen Subdivision Algorithm University of Sulaimani - School of Science - Computer Dept.

Group Discussion