2 D viewing Prepared by Elizabeth Isaac DCS, RSET.

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

มุมมองใน 2 มิติ (2-D Viewing)
Computer Graphics 4: Viewing In 2D
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.
Course Website: Computer Graphics 4: Viewing In 2D.
Two-Dimensional Viewing Jehee Lee Seoul National University.
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
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
Lecture 7 2D viewing 1 Lecture 7. 2D Viewing 2D viewing pipeline Clipping window, Normalization viewport transformation OpenGL 2D viewing functions Setup.
CHAPTER 7 2D VIEWING CGMB214: Introduction to Computer Graphics.
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 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Two Dimensional Viewing Dr. Eng. Farag Elnagahy
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,
2D Viewing. 2D viewing transformation is a mapping of world coordinate scene to device coordinates xw min xw max yw min yw max xv min xv max yv min yv.
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.
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.
Two Dimensional Viewing
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.
2 DIMENSIONAL VIEWING Ceng 477 Introduction to Computer Graphics Fall Computer Engineering METU.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 2D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Clipping Computer Graphics Cohen Sutherland Algorithm (Line)
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Windows, Viewports, and Clipping
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 1 1.
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
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
CS552: Computer Graphics Lecture 6: Viewing in 2D.
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.
Graphics Graphics & Graphical Programming Lecture 23 - Viewing & Clipping.
A.Aruna/Assistant Professor/SNSCE
Perspective View Volume View Volume Far Near Window Far Near Window Center of Projection Center of Projection (a) Original Orientation (b) After Transformation.
Chapter: Viewing.
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Clipping.
Two-Dimensional Viewing Hearn & Baker Chapter 6
Computer Graphic 2 D Viewing.
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
Two-Dimensional Viewing
2D Viewing & Clipping 한신대 류승택
2D Viewing Pipeline.
Graphics Pipeline Clipping
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
WINDOWING AND CLIPPING
WINDOWING AND CLIPPING
Two Dimensional Viewing and Clipping.
3D Viewing.
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Presentation transcript:

2 D viewing Prepared by Elizabeth Isaac DCS, RSET

The Viewing Pipeline Viewing transformations in several steps Window to Viewport. Window: A region of the scene selected for viewing (also called clipping window) Viewport: A region on display device for mapping to window 2-D viewing transformation referred to as Window –to-Viewport Transformation or windowing transformation

World Coordinates Viewing Coordinates Window Viewport The Viewing Pipeline

A viewing transformation using standard rectangles for the window and viewport World Coordinates xv min xv max yw max yw min Device Coordinate xv min xv max yv max yv min

The two-dimensional viewing- transformation pipeline Construct World Coordinate Scene Using Modeling-Coordinate Transformation Convert World-Coordinates to Viewing Coordinates Map Viewing Coordinates to Normalized Viewing Coordinates using Window-Viewport Specifications Map Normalized Viewport to Device Coordinates

Setting up a rotated world window in viewing coordinates and the corresponding normalized- coordinate viewport Normalized Device Coordinates Viewpoint World Coordinates y view x view y world y0y0 x0x0 x world

Viewing Coordinate Reference Frame The steps in this coordinate transformation – A viewing coordinate frame is moved into coincidence with the world frame in two steps a)Translate the viewing origin to the world origin, then b)Rotate to align the axes of the two systems

Viewing Coordinate Reference Frame

Matrix for converting world-coordinate positions to viewing coordinate R: rotation matrix T: translation matrix

Window-To-Viewport Coordinate Transformation A point at position (xw, yw) in a designated window is mapped to viewport coordinates (xv, yv) so that relative positions in the two areas are the same

Window-To-Viewport Coordinate Transformation To maintain the same relative placement

Window-To-Viewport Coordinate Transformation Solving these expressions The scaling factors

Window-To-Viewport Coordinate Transformation Conversion sequence of transformation 1.Perform a scaling transformation using a fixed- point position of (xw min, yw min ) that scales the window area to the size of the viewport 2.Translate the scaled window area to the position of the viewport

Window-To-Viewport Coordinate Transformation Workstation transformation – Opening any number of output devices in a particular application – Performing another window-to-viewport transformation for each open output device

Window-To-Viewport Coordinate Transformation

Two-Dimensional Viewing Functions Setting up the elements of a window-to- viewport mapping matrix evaluateViewMappingMatrix (xwmin, xwmax, ywmin, ywmax, xvmin, xvmax, yvmin, yvmax, error, viewMappingMatrix)

Two-Dimensional Viewing Functions Selection of a workstation window-viewport pair – setWorkstationWindow (ws, xwsWindmin, xwsWindmax, ywsWindmin, ywsWindmax) – setWorkstationViewport (ws, xwsVPortmin, xwsVPortmax, ywsVPortmin, ywsVPortmax)

Clipping Any procedure that identifies those portions of a picture that are either inside or outside of a specified region of space is referred to as a clipping algorithm or clipping Clip window

Clipping – Point – Line – Area (or Polygons) – Curve – Text

Clipping Point Clipping Assuming that the clip window is a rectangle in standard position Saving a point P=(x, y) for display

Line Clipping Line clipping against a rectangular clip window

Line Clipping

Cohen-Sutherland Line Clipping Four digit binary code - Region Code Identifies the location of the point relative to the boundaries of the clipping rectangle Bit 1: left Bit 2: right Bit 3: below Bit 4: above 4321

Cohen-Sutherland Line Clipping

– Calculate differences between endpoint coordinates and clipping boundaries – Use the resultant sign bit of each difference calculation to set the corresponding value in the region code

Region code divide space into 9 regions Computation of region code requires at most 4 subtractions b 0 = 1 if y > y max, 0 otherwise b 1 = 1 if y < y min, 0 otherwise b 2 = 1 if x > x max, 0 otherwise b 3 = 1 if x < x min, 0 otherwise

Cohen-Sutherland Line Clipping Outside Line Removal Test – A method that can be used to test lines total clipping is to perform the logical and operation with both region codes – Not 0000 Completely outside the clipping region!! Lines that cannot be identified as completely inside or outside a clip window by this test

Cohen-Sutherland Line Clipping

Intersection Point Calculate Intersection Point – Using the slope-intercept form – Vertical Boundary – Horizontal Boundary

1. Start 2. Read two end points of a line P1,P2 (x1,y1) and (x2,y2) 3. Read two corners of window(wx1,wy1) and(wx2,wy2) 4. Assign the region codes for two end points using following steps – a. Set bit 1 if x < wx1 – b. Set bit 2 if x>wx2 – c. Set bit 3 if y<wy2 – d. Set bit 4 if y> wy1

5. Check for the visibility of the line – a. If region codes for both end points are 0 then the line is completely visible. Draw the line. Go to 10 – b. If the region codes are not zero and the logical AND ing of them is also non zero then the line is completely invisible. Go to 10 – c. If the region codes for two end points do not satisfy the conditions in 5 a and 5 b the line is partially visible

6. Determine the intersecting edge of the clipping window by inspecting the region codes of two end points – a. If the region codes foe both end points are non zero find the intersection point P1’ and P2’ with boundary edges of clipping window with respect to P1 and P2 respectively – b. If the region code for any one end point is non zero then find intersection point P1’ or P2’ with the boundary edge of the clipping window with respect to it.

7. Divide the line segments considering the intersection points 8. Reject the line segment if any one end point of it appears outside the clipping window 9. Draw the remaining line segments 10. Stop.

Polygon Clipping

36 Sutherland-Hodgman Clipping

37 Sutherland-Hodgman Clipping

38 Sutherland-Hodgman Clipping

39 Sutherland-Hodgman Clipping

40 Sutherland-Hodgman Clipping

41 Sutherland-Hodgman Clipping

42 Sutherland-Hodgman Clipping

43 Sutherland-Hodgman Clipping

Sutherland-Hodgeman Polygon Clipping

4 possible cases

Sutherland-Hodgeman Polygon Clipping

Weiler-Atherton Polygon Clipping Rules – For an outside-to-inside pair of vertices, follow the polygon boundary – For an inside-to-outside pair of vertices, follow the window boundary in clockwise direction

Other Polygon-Clipping Algorithm Clipping a polygon by determining the intersection of two polygon areas

Text clipping

All-or-none string clipping – No text is retained after clipping since part of text is outside clip window

Text clipping All-or-none character clipping – Only “ B ” and “ C ” are retained after clipping since part of “ A ” is outside clip window

Text clipping Character component clipping – All of “ B ” and “ C ” are retained, and those parts of “ A ” inside clip window are also retained

interior clipping – what is to be saved is inside the clip window exterior clipping – what is to be saved is outside clip window Interior clipping - keep point P2 P2 (x2, y2)

Exterior Clipping Exterior clipping - keep point P1 Clip window P1 (x1, y1)