Download presentation
Presentation is loading. Please wait.
Published byJasmine Jenkins Modified over 9 years ago
1
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 1 1
2
2 Two-Dimensional Viewing Co-ordinate Systems. Cartesian – offsets along the x and y axis from (0.0) Polar – rotation around the angle . Graphic libraries mostly using Cartesian co-ordinates Any polar co-ordinates must be converted to Cartesian co- ordinates Four Cartesian co-ordinates systems in computer Graphics. 1. Modeling co-ordinates 2. World co-ordinates 3. Normalized device co-ordinates 4. Device co-ordinates
3
3 Modeling Coordinates Also known as local coordinate. Ex: where individual object in a scene within separate coordinate reference frames. Each object has an origin (0,0) So the part of the objects are placed with reference to the object’s origin. In term of scale it is user defined, so, coordinate values can be any size.
4
4 World Co-ordinates. The world coordinate system describes the relative positions and orientations of every generated objects. The scene has an origin (0,0). The object in the scene are placed with reference to the scenes origin. World co-ordinate scale may be the same as the modeling co- ordinate scale or it may be different. However, the coordinates values can be any size (similar to MC)
5
5 Normalized Device Co-ordinates Output devices have their own co-ordinates. Co-ordinates values: The x and y axis range from 0 to 1 All the x and y co-ordinates are floating point numbers in the range of 0 to 1 This makes the system independent of the various devices coordinates. This is handled internally by graphic system without user awareness.
6
6 Device Co-ordinates Specific co-ordinates used by a device. Pixels on a monitor Points on a laser printer. mm on a plotter. The transformation based on the individual device is handled by computer system without user concern.
7
7 Two-Dimensional Viewing Example: Graphic program which draw an entire building by an architect but we only interested on the ground floor Map of sales for entire region but we only like to know from certain region of the country.
8
8 Two-Dimensional Viewing When we interested to display certain portion of the drawing, enlarge the portion, windowing technique is used Technique for not showing the part of the drawing which one is not interested is called clipping An area on the device (ex. Screen) onto which the window will be mapped is called viewport. Window defines what to be displayed. A viewport defines where it is to be displayed. Most of the time, windows and viewports are usually rectangles in standard position(i.e aligned with the x and y axes). In some application, others such as general polygon shape and circles are also available However, other than rectangle will take longer time to process.
9
9 Viewing Transformation Viewing transformation is the mapping of a part of a world- coordinate scene to device coordinates. In 2D (two dimensional) viewing transformation is simply referred as the window-to-viewport transformation or the windowing transformation. Mapping a window onto a viewport involves converting from one coordinate system to another. If the window and viewport are in standard position, this just involves translation and scaling. if the window and/or viewport are not in standard, then extra transformation which is rotation is required.
10
10 Viewing Transformation 0 1 1 x-world y-world window Normalised device world y-view x-view
11
11 Window-To-Viewport Coordinate Transformation Window-to-Viewport transformation
12
12 Window-To-Viewport Coordinate Transformation. XWmax YWmax XWmin YWmin XVmaxXVmin YVmax YVmin xw,yw xv,yv
13
13 Window-To-Viewport Coordinate Transformation xv - xv min= xw - xw min xv - xv min= xw - xw min xv max - xv min xw max - xw min xv max - xv min xw max - xw min yv – yv min = yw - yw min yv max – yv min yw max - yw min From these two equations we derived xv = xv min + (xw – xw min )sx yv = yv min + (yw – yw min )sy where the scaling factors are sx = xv max – xv min sy = yv max - yv min sx = xv max – xv min sy = yv max - yv min xw max – xw min yw max - yw min xw max – xw min yw max - yw min
14
14 Window-To-Viewport Coordinate Transformation The sequence of transformations are: 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.
15
15 Window-To-Viewport Coordinate Transformation Relative proportions of objects are maintained if the scaling factors are the same (sx = sy). Otherwise, world objects will be stretched or contracted in either x or y direction when displayed on output device. about character strings when map to viewport? How about character strings when map to viewport? maintains a constant character size (apply when standard character fonts cannot be changed). If character size can be changed, then windowed will be applied like other primitives. For characters formed with line segments, the mapping to viewport is carried through sequence of line transformations. For characters formed with line segments, the mapping to viewport is carried through sequence of line transformations.
16
16 Viewport-to-Normalized Device Coordinate Transformation From normalized coordinates, object descriptions can be mapped to the various display devices When mapping window-to-viewport transformation is done to different devices from one normalized space, it is called workstation transformation.
17
17 The Viewing Pipeline
18
18 OpenGL 2D Viewing Functions To transform from world coordinate to screen coordinates, the appropriate matrix mode must be chosen glMatrixMode (GL_PROJECTION); glLoadIdentity( ); To define a 2D clipping window, we use OpenGL Utility function: gluOrtho2D( xwmin, xwmax, ywmin, ywmax); This function also perform normalization (NDC)
19
19 OpenGL 2D Viewing Functions To specify the viewport parameters in OpenGL, we use function glViewport(xvmin, yvmin, vpWidth, vpHeight);
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.