Download presentation
Presentation is loading. Please wait.
Published byShannon Cathleen Mosley Modified over 9 years ago
1
Basic graphics
2
ReviewReview Viewing Process, Window and viewport, World, normalized and device coordinates Input and output primitives and their attributes. Rendering. Vector and raster displays Basic graphics in an universal programming system Vector Algebra Homogeneous Coordinates and Transformation of Space
3
PreliminariesPreliminaries What newcomers to Shape Modeling and Computer Graphics have to know Fundamental ideas and vocabulary in Geometrical Modeling and Computer graphics Graphics and geometry APIs Transformations Curves and surfaces design Rendering technique Physics-based approaches for modeling …
4
OverviewOverview Are they shadows that we see? And can shadows pleasure give? Pleasures only shadows be Cast by bodies we conceive And are made the things we deem In those figures which they seem From Are They Shadows by Samuel Daniel
5
3D Viewing Many of the 3D images seen on a screen are really a trick of the eye. The modeling is performed in 3D, but the rendering has to be converted to 2D
6
3D Viewing
8
A useful metaphor for creating 3D scenes is the motion of a synthetic camera We imagine that we can move our camera to any location, orient it in any way we wish, and, with a snap of the shutter, create a 2D image (“photo”) of a 3D object The camera, of course, is really just a computer program that produces an image on a display screen
9
3D Viewing Rendering is the process by which a computer creates images from models The rendering of 3D pictures is accomplished through projection: draw a line from the eye (P 0 ) with a straight line to the (x,y,z)
10
3D Viewing Creation of our “photo” is accomplished as a series of steps: Specification of projection type to transform 3D objects onto a 2D projection plane Specification of viewing parameters. We must specify the conditions under which we want to view the 3D real world dataset Clipping in three dimensions. We must ignore parts of the scene that are not candidates for ultimate display
11
3D Viewing Given that output primitives are specified in world coordinates, the graphics subroutine package must be told how to map world coordinates onto screen coordinates or device coordinates So if we have world-coordinate window, and a corresponding rectangular region in screen coordinates, called the viewport, we have to produce the transformation that maps the window into the viewport
12
3D Viewing We may want to ignore parts of the scene that are behind us or too far distant to be clearly visible The view volume bounds that portion of the world that is to be clipped out and projected onto the view plane
13
3D Viewing In the output pipeline, the application program takes description of objects in terms of primitives and attributes stored in or derived from an application model or data structure, and specifies them to the graphics package, which in turn clips and converts them to the pixels seen on the screen CG packages supports a basic collection of primitives: lines, polygons, circles and ellipses, and text
14
3D Viewing Raster displays store the display primitives in a refresh buffer in terms of the primitive’s component pixel Pixels are points of a rectangular array or the smallest visible elements that the display hardware can put on the screen
15
Basic graphics in an universal programming system (OpenGL) The OpenGL graphics system is a software interface to graphics hardware It allows you to create interactive programs that produce color images of moving three- dimensional objects With OpenGL, you must build up your desired model from a small set of geometric primitives – points, lines, and polygons
16
Basic graphics in an universal programming system (OpenGL) The OpenGL Utility Library (GLU) provides many of the modeling features, such as quadric surfaces and NURBS OpenGL is a state machine. You put it into various states that then remain in effect until you change them Many state variables refer to modes that are enabled or disabled
17
Basic graphics in an universal programming system (OpenGL) All data, whether it describes geometry or pixels, can be saved in a display list for current or later use All geometric primitives are eventually described by vertices. Parametric curves and surfaces may be initially described by control points. Evaluators provide a method to derive the vertices You can handle input events and register callback command that are invoked when specified events occur, for instance when the mouse is moved while a mouse button is also pressed
18
Basic graphics in an universal programming system (OpenGL) One of the most exciting things you can do on a graphical computer is draw pictures that move, or animate objects Most OpenGL implementation provide double- buffering – hardware or software that supplies two complete color buffers. Once is displayed while the other is being drawn. When the drawing of a frame is complete, the two buffers are swapped
19
Vector Algebra A vector is a mathematical entity with two attributes: direction and magnitude. The magnitude of vector P =(x,y,z) is |P| = The direction of a vector can be expressed by the cosines of the angles it makes with the coordinate axis x/|P|, y/ |P|, z/|P|. The three unit vectors in the directions of the coordinate axes are traditionally denoted i = (1,0,0), j = (0,1,0) and k = (0,0,1).
20
Vector Algebra Vectors permit two fundamental operations: You can add them and you can multiply them by scalars. Let a 1 = a 1 i, a 2 = a 2 j, a 3 = a 3 k, and b 1 = b 1 i, b 2 = b 2 j, b 3 = b 3 k. We can write a + b = (a 1 + b 1 )i + (a 2 + b 2 )j + (a 3 + b 3 )k, a = a 1 i + a 2 j + a 3 k. To form a linear combination of two vectors, a and b, we scale each of them by some scalars, say, and and add the weighted versions to form new vector, a + b.
21
Vector Algebra The dot product of two vectors. To calculate the dot product we multiply corresponding components of the vectors and add the result. The cross product (also called the vector product) of two vectors is another vector. Given the 3D vectors a = (a x,a y,a z ), and b = (b x,b y,b z ), their cross product is denoted as a b or a b. It is defined in terms of the standard unit vector i,j, and k by a b = (a x b z – a z b y )i + (a z b x – a x b z )j + (a x b y – a y b x )k.
22
Vector Algebra Vector equation of line. Suppose we are given a point P 0 and a unit vector u along the line L. Give the names r 0 and r to the vectors OP 0 and OP connecting the point O with the point P 0 and an arbitrary point P, respectively. Then the vector P 0 P = r – r 0 coincides with the direction of the vector u, so r – r 0 = u. And we have r = r 0 + u.
23
Vector Algebra Vector differentiation. If a vector a is the function of time t, a(t) = a 1 (t) i + a 2 (t) j + a 3 (t) k, then = i + j + k.
24
Homogeneous Coordinates and Transformation of Space Each primitive has a mathematical representation which can be expressed as a data or type structure fore storage and manipulation by a computer Applying transformations to graphical primitives can be done by a process called instancing
25
ProjectionsProjections 3D objects can be projected on 2D view plane There are two basic methods: –parallel projection –perspective projection The parallel projection can be considered as a special case of of perspective projection
26
ProjectionsProjections Orthographic Parallel Projections The most common type of orthographic projection is the front- elevation
27
Homogeneous Coordinates and Transformation of Space A point (x, y, z) in three dimensional Cartesian space is represented in R 4 by the vector (x, y, z, 1), or by any multiple (rx, ry, rz,r) (with, r 0). When W 0, the homogeneous coordinates (X, Y. Z. W) represent the Cartesian point (x, y, z = (X/W, Y/W, Z/W) A point of the form (X, Y, Z,0) does not correspond to a Cartesian point, but represents the point at infinity in the direction of the three-dimensional vector (X, Y, Z). The set of all homogeneous coordinates (X, Y, Z. W) is called (three-dimensional) projective space and denoted P 3
28
Homogeneous Coordinates and Transformation of Space A transformation of projective space is a mapping L: P 3 P 3 of the form The 4 4 matrix M is called the homogeneous transformation matrix of L. If M is a non-singular matrix then L is called a non- singular transformation. If m 14 = m 24 = m 34 = 0 and m 44 0, then L is said to be an affine transformation. (Affine transformations correspond to translations, scalings, rotations etc. of three- dimensional Cartesian space.) A point of the form (X, Y, Z,0) does not correspond to a Cartesian point, but represents the point at infiniy
29
Homogeneous Coordinates and Transformation of Space Translations - The transformation matrix of a translation by x 0, y 0, and z 0 units in the x-, y- and z- directions respectively, is - Hence, P(x, y, z) is transformed to P'(x + x 0, y + y 0, z + z 0 )
30
Homogeneous Coordinates and Transformation of Space Scalings and Reflections - A scaling about the origin by a factor s x, s y, and s z, in the x-, y-, and z-direction,is respectively, obtained by the following transformation matrix - The transformation matrices of the reflections R yz in the x = 0 plane, R xz, in the y = 0 plane, and R xy in the z = 0 plane, are obtained by taking a scaling of -1 in one of the coordinate directions
31
Homogeneous Coordinates and Transformation of Space Rotations about the Coordinate Axes - Rotations in space take place about a line called its rotation axis - The rotations about the three coordinate axes are called the primary rotations 1. Rotation about the x-axis through an angle x 2. Rotation about the y-axis through an angle y 3. Rotation about the z-axis through an angle z
32
Homogeneous Coordinates and Transformation of Space Rotation about an Arbitrary Line - Rotation through an angle about an arbitrary rotation axis is obtained by transforming the rotation axis to one of the coordinate axes, applying a primary rotation through an angle about the coordinate axis, and applying the transformation which maps the coordinate axis back to the rotation axis
33
Homogeneous Coordinates and Transformation of Space Rotation about an Arbitrary Line 1.Apply the translation T(-p l,-p 2 -p 3 ) which maps P to the origin and the rotation axis to the line OR where R(r 1,r 2,r 3 )= U 2.Suppose r 2 and r 3 are not both zero. Apply a rotation through all angle x, about the x-axis so that the line OR is mapped into the xz-plane 3.Apply a rotation about the y-axis so that the line OR' is mapped to the z-axis. 4.Apply a rotation through an angle about the z-axis (Figure 2(c)). 5.Apply the inverses of the transformations 1-3 in reverse order
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.