CH 04 6up
CH 04 6up
■ Introduction:
- We are now ready to concentrate on three-
dimensional graphics
- Much of this chapter is concerned with
Geometric Objects and matters such as
Transformations • how to represent basic geometric types
• how to convert between various
representations
Chapter 4 • and what statements we can make about
geometric objects, independent of a particular
representation.
- In computer graphics, we often connect • Directed line segments can have their lengths
points with directed line segments and directions changed by real numbers or by
combining vectors
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 5 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 6
- -1
- -
■ 1.2 The Mathematical View: Vector and - Perhaps the most important mathematical
Affine Spaces space is the vector space
• We can regard scalars, points and vectors as • A vector space contains two distinct entities:
members of mathematical sets; vectors and scalars.
• Then look at a variety of abstract spaces for • There are rules for combining scalars through
representing and manipulating these sets of two operations: addition and multiplication, to
objets. form a scalar field
• The formal definitions of interest to us -- vector
spaces, affine spaces, and Euclidean spaces -- • Examples of scalar are:
are given in Appendix B – real numbers, complex numbers, and rational
functions
• You can combine scalars and vectors to forma
new vector through
– scalar-vector multiplication and vector-vector addition
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 7 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 8
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 9 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 10
- -2
- -
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 15 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 16
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 17 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 18
- -3
- -
- In 2D we had objects
2. Three-Dimensional Primitives with interiors, such as
polygons,
- In a three-dimensional world, we can have - Now we have surfaces
a far greater variety of geometric objects in space
than we could in two-dimensions.
• In 2D we had curves,
• Now we can have curves in space
- In addition, now we can
have objects that have
volume
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 19 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 20
• We face two issues when moving from 2D to • We can understand why we set these
3D. conditions if we consider what most modern
– First, the mathematical definitions of these objects graphics systems do best:
becomes complex – They render triangles
– Second, we are interested in only those objects that
lead to efficient implementations in graphic systems
• Def: tesselate
• Three features characterize 3D objects that fit
well with existing graphics hardware and
software:
– 1. The objects are described by their surfaces and
can be thought of as hollow.
– 2. The objects can be specified through a s set of
vertices in 3D
– 3. The objects either are composed of or can be
approximated by flat convex polygons.
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 21 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 22
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 23 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 24
- -4
- -
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 25 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 26
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 27 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 28
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 29 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 30
- -5
- -
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 31 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 32
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 33 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 34
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 35 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 36
- -6
- -
• Let’s look at a simple example: – Thus by making d a suitably large positive number,
– In the default settings, the camera and the world we move the objets in front of the camera
frame coincide with the camera pointing in the
negative z direction – Figure 4.21
– In many applications it is natural to define objects
near the origin.
• If we regard the camera frame as fixed, then – Note that, as far as the user - who is working in world
the model-view matrix: coordinates - is concerned, they are positioning
1 0 0 0 objects as before
0 1 0 0 – The model-view matrix takes care of the relative
A= positioning of the frames
0 0 1 −d
0 0 0 1
– moves a point (x,y,z) in the world frame to the point
(x,y,z-d) in the camera frame.
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 37 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 38
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 39 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 40
■ 4.2 Inward- and Outward-Pointing ■ 4.3 Data Structures for Object Representation
Faces • We could describe our cube
– glBegin(GL_POLYGON)
• We have to be careful about the order in which
• six times, each followed by four vertices
we specify our vertices when we are defining a
– glBegin(GL_QUADS)
three-dimensional polygon
• followed by 24 vertices
• We call a face outward facing if the vertices
• But these repeat data....
are traversed in a counterclockwise order when
the face is viewed from the outside. • Let’s separate the topology from the geometry.
– This is also known as the right-hand rule
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 41 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 42
- -7
- -
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 45 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 46
• glEnableClientState(GL_COLOR_ARRAY);
• glEnableClientState(GL_VERTEX_ARRAY);
• glVertexPointer(3, GL_FLOAT, 0, vertices); 5. Affine Transformations
• glColorPointer(3, GL_FLOAT, 0, colors);
– glDrawElements(GL_QUADS, 24,
GL_UNSIGNED_BYTE, cubeIndeces);
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 47 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 48
- -8
- -
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 49 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 50
x′ cosθ − sin θ x
y ′ = sin θ cosθ y
– 3) 2D rotation in the plane is equivalent to 3D
rotation about the x axis.
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 53 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 54
- -9
- -
• We can use these observations to define a • Rotations and translation are known as rigid-
general 3D rotation that is independent of the body transformations.
frame. – No combination can alter the shape of an object,
– To do this we must specify: – They can alter only the object’s location and
• a fixed point: Pf orientation
• a rotation angle: θ • The transformation given in this figure are
• a line or vector about which to rotate: affine, but they are not rigid-body
transformations
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 55 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 56
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 57 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 58
- -10
- -
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 61 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 62
cosθ 0 sin θ 0
0 1 0 0
R y = R y (θ ) =
− sin θ 0 cosθ 0
0 0 0 1
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 63 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 64
- -11
- -
• You do this:
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 67 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 68
- -12
- -
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 73 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 74
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 77 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 78
- -13
- -
CS 480/680 Chapter 4 -- Geometric Objects and Transformations 79 CS 480/680 Chapter 4 -- Geometric Objects and Transformations 80
- -14