You are on page 1of 36

Computer Graphics 7:

Viewing in 3-D

Contents
In todays lecture we are going to have a
look at:
Transformations in 3-D
How do transformations in 3-D work?
3-D homogeneous coordinates and matrix based
transformations

Projections

History
Geometrical Constructions
Types of Projection
Projection in Computer Graphics

3-D Coordinate Spaces


Remember what we mean by a 3-D
coordinate space
y axis

z
x
z axis

x axis

Right-Hand
Reference System

Translations In 3-D
To translate a point in three dimensions by
dx, dy and dz simply calculate the new
points as follows:

x = x + dx

y = y + dy

z = z + dz

(x, y, z)
(x, y, z)
Translated Position

Scaling In 3-D
To sale a point in three dimensions by sx, sy
and sz simply calculate the new points as
follows:

x = sx*x

y = sy*y

z = sz*z

(x, y, z)

(x, y, z)

Scaled Position

Rotations In 3-D (cont)


The equations for the three kinds of
rotations in 3-D are as follows:

x = xcos - ysin
y = xsin + ycos
z = z

x = x
y = ycos - zsin
z = ysin + zcos

x = zsin + xcos
y = y
z = zcos - xsin

Homogeneous Coordinates In 3-D


Similar to the 2-D situation we can use
homogeneous coordinates for 3-D
transformations - 4 coordinate y axis
column vector
y
All transformations can
then be represented
as matrices
P
P(x, y, z) =

x
y

z

1

z
x
z axis

x axis

3D Transformation Matrices
1
0
Translation by
dx, dy, dz 0

0
0
1
0 cos

0 sin

0
0

0
sin
cos
0

0
0
0

Rotate About X-Axis

0 0 dx
1 0 dy
0 1 dz

0 0 1

sx
0

cos
0

sin

0 sin 0
1 0 0
0 cos 0

0 0 1

0 0 0
sy 0 0 Scaling by
0 sz 0 sx, sy, sz

0 0 1

Rotate About Y-Axis

cos
sin

sin
cos
0
0

0 0
0 0
1 0

0 1

Rotate About Z-Axis

Remember The Big Idea

10
of
23

Viewing a 3D world

World coordinate frame


Display plane

Camera position (or eye point, view point, viewing position)

(Variation of Fig 7-11, pg. 299)

3D Viewing Pipeline
Modeling coordinates

Construct World Coordinate


Scene Using ModelCoordinate Transformations

Modeling coordinates
Construct World Coordinate
Scene Using ModelCoordinate Transformations

World coordinates

3D pipeline
World coordinates

Convert World Coordinates to


Viewing Coordinates
Viewing coordinates

Convert World Coordinates to


Viewing Coordinates

Projection Transformation
Viewing coordinates
2D pipeline
Transform Viewing
Coordinates to Normalized
Coordinates
Normalized coordinates
Map Normalized Coordinates
to Device Coordinates
Device coordinates

Projection coordinates
Transform Viewing
Coordinates to Normalized
Coordinates
Normalized coordinates
Map Normalized Coordinates
to Device Coordinates
Device coordinates

What Are Projections?


Our 3-D scenes are all specified in 3-D
world coordinates
To display these we need to generate a 2-D
image - project objects onto a picture plane
Picture Plane

Objects in
World Space

So how do we figure out these projections?

Converting From 3-D To 2-D


Projection is just one part of the process of
converting from 3-D world coordinates to a
2-D image
3-D world
coordinate
output
primitives

Clip against
view volume

Project onto
projection
plane

Transform to
2-D device
coordinates

2-D device
coordinates

Projections
Need to project from 3D to 2D
2 kinds of projection
Parallel projection
Perspective projection

Parallel Projection

Perspective Projection

Types Of Projections
There are two broad classes of projection:
Parallel: Typically used for architectural and
engineering drawings
Perspective: Realistic looking and used in
computer graphics

Parallel Projection

Perspective Projection

Types Of Projections (cont)


For anyone who did engineering or technical
drawing

Parallel Projections
Some examples of parallel projections

Orthographic Projection
Isometric Projection

Perspective Projections
There are a number of different kinds of
perspective views
The most common are one-point and two
point perspectives

One Point Perspective


Projection

Two-Point
Perspective
Projection

Elements Of A Perspective Projection

Virtual
Camera

The Up And Look Vectors


Projection of
up vector

Up vector

Position

Look vector

The look vector


indicates the direction in
which the camera is
pointing
The up vector
determines how the

camera is rotated
For example, is the camera held vertically or
horizontally

Summary
In todays lecture we looked at:
Transformations in 3-D
Very similar to those in 2-D

Projections
3-D scenes must be projected onto a 2-D image
plane
Lots of ways to do this
Parallel projections
Perspective projections

The virtual camera

Perspective Projections
Remember the whole point of perspective
projections

Setting Up A Perspective Projection


(cont)
We need one more thing to specify a
perspective projections using the filed of
view angle
The aspect ratio gives the ratio between the
width sand height of the view plane

Contents
Now lecture we are going to have a look at
some perspective view demos and
investigate how clipping works in 3-D
Nate Robins OpenGL tutorials
The clipping volume
The zone labelling scheme
3-D clipping
Point clipping
Line clipping
Polygon clipping

3-D Clipping
Just like the case in two dimensions,
clipping removes objects that will not be
visible from the scene
The point of this is to remove computational
effort
3-D clipping is achieved in two basic steps
Discard objects that cant be viewed
i.e. objects that are behind the camera, outside
the field of view, or too far away

Clip objects that intersect with any clipping


plane

Discard Objects
Discarding objects that cannot possibly be
seen involves comparing an objects
bounding box/sphere against the
dimensions of the view volume
Can be done before or after projection

Clipping Objects
Objects that are partially within the viewing
volume need to be clipped just like the 2D
case

Normalisation
The transformed volume is then normalised
around position (0, 0, 0) and the z axis is
reversed

Dividing Up The World


Similar to the case in two dimensions, we
divide the world into regions
This time we use a 6-bit region code to give
us 27 different region codes
The bits in these regions codes are as
follows:
bit 6
Far

bit 5
Near

bit 4
Top

bit 3
Bottom

bit 2
Right

bit 1
Left

Region Codes

3D Line Clipping Example (cont)


When then simply continue as per the two
dimensional line clipping algorithm

3D Polygon Clipping
However the most common case in 3D
clipping is that we are clipping graphics
objects made up of polygons

3D Polygon Clipping (cont)


In this case we first try to eliminate the entire
object using its bounding volume
Next we perform clipping on the individual
polygons using the Sutherland-Hodgman
algorithm we studied previously

Summary
In todays lecture we examined how clipping
is achieved in 3-D

You might also like