Title: Basic graphics
1Basic graphics
2Review
- 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
3Preliminaries
- 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
-
4Overview
- 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
53D 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
63D Viewing
73D Viewing
83D Viewing
- 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
93D 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 (P0)
with a straight line to the (x,y,z)
103D 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
113D 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
123D 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
133D 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
143D Viewing
- Raster displays store the display primitives in a
refresh buffer in terms of the primitives
component pixel - Pixels are points of a rectangular array or the
smallest visible elements that the display
hardware can put on the screen
15Basic 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
16Basic 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
17Basic 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
18Basic 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
19Vector 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).
20Vector Algebra
- Vectors permit two fundamental operations You
can add them and you can multiply them by
scalars. - Let
- a1 a1i, a2 a2j, a3 a3k, and
- b1 b1i, b2 b2j, b3 b3k. We can write
- a b (a1 b1)i (a2 b2)j (a3 b3)k ,
- ?a ?a1 i ?a2 j ?a3k .
- 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.
21Vector 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 (ax,ay,az), and b (bx,by,bz),
- 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 (axbz azby)i (azbx axbz)j (axby
aybx)k.
22Vector Algebra
- Vector equation of line. Suppose we are given a
point P0 and a unit vector u along the line L.
Give the names r0 and r to the vectors OP0 and
OP connecting the point O with the point P0 and
an arbitrary point P, respectively. Then the
vector P0P r r0 coincides with the direction
of the vector u, so - r r0 ? u. And we have
- r r0 ? u.
23Vector Algebra
- Vector differentiation. If a vector a is the
function of time t, a(t) a1(t) i a2(t) j
a3(t) k, then - i j k.
24Homogeneous 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
25Projections
- 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
26Projections
- Orthographic Parallel Projections
- The most common type of orthographic projection
is the front-elevation
27Homogeneous Coordinates and Transformation of
Space
- A point (x, y, z) in three dimensional Cartesian
space is represented in R4 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 P3
28Homogeneous Coordinates and Transformation of
Space
- A transformation of projective space is a
mapping L P3 ? P3 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 m14 m24 m34
0 and m44 ? 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
29Homogeneous Coordinates and Transformation of
Space
- Translations
- - The transformation matrix of a translation by
x0, y0, and z0 units in the x-, y- and z-
directions respectively, is - - Hence, P(x, y, z) is transformed to P'(x x0,
y y0, z z0)
30Homogeneous Coordinates and Transformation of
Space
- Scalings and Reflections
- - A scaling about the origin by a factor sx, sy,
and sz, in the x-, y-, and z-direction ,is
respectively, obtained by the following
transformation matrix - - The transformation matrices of the reflections
Ryz in the x 0 plane, Rxz, in the y 0 plane,
and Rxy in the z 0 plane, are obtained by
taking a scaling of -1 in one of the coordinate
directions
31Homogeneous 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
32Homogeneous 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
33Homogeneous Coordinates and Transformation of
Space
- Rotation about an Arbitrary Line
- Apply the translation T(-pl,-p2 -p3) which maps P
to the origin and the rotation axis to the line
OR where R(r1,r2,r3) U - Suppose r2 and r3 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 - Apply a rotation about the y-axis so that the
line OR' is mapped to the z-axis. - Apply a rotation through an angle ? about the
z-axis (Figure 2(c)). - Apply the inverses of the transformations 1-3 in
reverse order