1 / 80

Computer Graphics with Open GL, 4th edition, Hearn, Baker & Carithers .

Main Reference. Computer Graphics with Open GL, 4th edition, Hearn, Baker & Carithers. Chapter Seven. Two-Dimensional Viewing. Content. The Two-Dimensional Viewing Pipeline OpenGL Two-Dimensional Viewing Functions. Two-Dimensional Viewing.

herndon
Télécharger la présentation

Computer Graphics with Open GL, 4th edition, Hearn, Baker & Carithers .

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Main Reference Computer Graphics with Open GL, 4th edition, Hearn, Baker & Carithers.

  2. Chapter Seven Two-Dimensional Viewing

  3. Content The Two-Dimensional Viewing Pipeline OpenGL Two-Dimensional Viewing Functions

  4. Two-Dimensional Viewing Typically, a graphics package allows a user to specify which part of a defined picture is to be displayed and where that part is to be placed on the display device.

  5. Two-Dimensional Viewing Any convenient Cartesian coordinate system, referred to as the world-coordinate reference frame, can be used to define the picture. For a two-dimensional picture, a view is selected by specifying a region of the xy plane that contains the total picture or any part of it. A user can select a single area for display, or several areas could be selected for simultaneous display or for an animated panning sequence across a scene. The picture parts within the selected areas are then mapped onto specified areas of the device coordinates.

  6. The Two-Dimensional Viewing Pipeline A section of a two-dimensional scene that is selected for display is called a clipping window because all parts of the scene outside the selected section are “clipped” off. Graphics packages allow us also to control the placement within the display window using another “window” called the viewport.

  7. The Two-Dimensional Viewing Pipeline Objects inside the clipping window are mapped to the viewport, and it is the viewport that is then positioned within the display window. The clipping window selects what we want to see; the viewport indicates where it is to be viewed on the output device. By changing the position of a viewport, we can view objects at different positions on the display area of an output device. Multiple viewports can be used to display different sections of a scene at different screen positions. Also, by varying the size of viewports, we can change the size and proportions of displayed objects.

  8. The Two-Dimensional Viewing Pipeline Usually, clipping windows and viewports are rectangles in standard position, with the rectangle edges parallel to the coordinate axes. Other window or viewport geometries, such as general polygon shapes and circles, are used in some applications, but these shapes take longer to process. We consider only rectangular viewports and clipping windows, as illustrated in Figure 1.

  9. The Two-Dimensional Viewing Pipeline

  10. The Two-Dimensional Viewing Pipeline The mapping of a two-dimensional, world-coordinate scene description to device coordinates is called a two-dimensional viewing transformation.

  11. OpenGL Two-Dimensional Viewing Functions Actually, the basic OpenGL library has no functions specifically for two dimensional viewing because it is designed primarily for three-dimensional applications. But we can adapt the three-dimensional viewing routines to a two dimensional scene, and the core library contains a viewport function.

  12. OpenGL Projection Mode

  13. GLU Clipping-Window Function

  14. OpenGL Viewport Function

  15. Creating a GLUT Display Window

  16. Setting the GLUT Display-Window Mode and Color

  17. GLUT Display-Window Identifier

  18. Deleting a GLUT Display Window

  19. Current GLUT Display Window

  20. Relocating and Resizing a GLUT Display Window

  21. Relocating and Resizing a GLUT Display Window

  22. Viewing Graphics Objects in a GLUT Display Window

  23. Executing the Application Program

  24. OpenGL Two-Dimensional Viewing Program Example

  25. OpenGL Two-Dimensional Viewing Program Example

  26. OpenGL Two-Dimensional Viewing Program Example

  27. OpenGL Two-Dimensional Viewing Program Example

  28. OpenGL Two-Dimensional Viewing Program Example

  29. Chapter Eight Three-Dimensional Geometric Transformations

  30. Content Three-Dimensional Translation Three-Dimensional Rotation Three-Dimensional Scaling Other Three-Dimensional Transformations OpenGL Geometric-Transformation Functions OpenGL Three-Dimensional Geometric- Transformation Programming Example

  31. Three-Dimensional Geometric Transformations Methods for geometric transformations in three dimensions are extended from two-dimensional methods by including considerations for the z coordinate.

  32. Three-Dimensional Translation A position P = (x, y, z) in three-dimensional space is translated to a location P = (x’, y’, z’) by adding translation distances tx, ty, and tzto the Cartesian coordinates of P: Figure 1 illustrates three-dimensional point translation.

  33. Three-Dimensional Translation

  34. Three-Dimensional Translation We can express these three-dimensional translation operations in matrix form. But now the coordinate positions, P and P’, are represented in homogeneous coordinates with four-element column matrices, and the translation operator T is a 4 × 4 matrix: or

  35. Three-Dimensional Translation An object is translated in three dimensions by transforming each of the defining coordinate positions for the object, then reconstructing the object at the new location. For an object represented as a set of polygon surfaces, we translate each vertex for each surface (Figure 2) and redisplay the polygon facets at the translated positions.

  36. Three-Dimensional Translation

  37. Three-Dimensional Rotation We can rotate an object about any axis in space, but the easiest rotation axes to handle are those that are parallel to the Cartesian-coordinate axes. Also, we can use combinations of coordinate-axis rotations (along with appropriate translations) to specify a rotation about any other line in space. Therefore, we first consider the operations involved in coordinate-axis rotations, then we discuss the calculations needed for other rotation axes.

  38. Three-Dimensional Rotation By convention, positive rotation angles produce counter-clockwise rotations about a coordinate axis, as shown in (Figure 3).

  39. Three-Dimensional Coordinate-Axis Rotations The two-dimensional z-axis rotation equations are easily extended to three dimensions, as follows: Parameter θ specifies the rotation angle about the z axis, and z-coordinate values are unchanged by this transformation. In homogeneous-coordinate form, the three-dimensional z-axis rotation equations are

  40. Three-Dimensional Coordinate-Axis Rotations Which we can write more compactly as Figure 4 illustrates rotation of an object about the z axis.

  41. Three-Dimensional Coordinate-Axis Rotations

  42. Three-Dimensional Coordinate-Axis Rotations Transformation equations for rotations about the other two coordinate axes can be obtained with a cyclic permutation of the coordinate parameters x, y, and z in Equations 4: Thus, to obtain the x-axis and y-axis rotation transformations, we cyclically replace x with y, y with z, and z with x, as illustrated in Figure 5.

  43. Three-Dimensional Coordinate-Axis Rotations

  44. Three-Dimensional Coordinate-Axis Rotations Substituting permutations 7 into Equations 4, we get the equations for an x-axis rotation: Rotation of an object around the x axis is demonstrated in Figure 6.

  45. Three-Dimensional Coordinate-Axis Rotations

  46. Three-Dimensional Coordinate-Axis Rotations A cyclic permutation of coordinates in Equations 8 gives us the transformation equations for a y-axis rotation: An example of y-axis rotation is shown in Figure 7.

  47. Three-Dimensional Coordinate-Axis Rotations An inverse three-dimensional rotation matrix is obtained in the same way as the inverse rotations in two dimensions. We just replace the angle θ with −θ.

  48. Three-Dimensional Scaling The matrix expression for the three-dimensional scaling transformation of a position P = (x, y, z) relative to the coordinate origin is a simple extension of two-dimensional scaling. We just include the parameter for z-coordinate scaling in the transformation matrix:

  49. Three-Dimensional Scaling The three-dimensional scaling transformation for a point position can be represented as Where scaling parameters sx, sy, and szare assigned any positive values. Explicit expressions for the scaling transformation relative to the origin are

More Related