You are on page 1of 23

1

of
23
New Lecture And Lab Information
Lectures:
– Thursday 12:00 – 13:00 (room tba)
– Friday 15:00 – 16:00 (A28)
Labs:
– Wednesday 10:00 – 11:00 (A305)
– Wednesday 17:00 – 18:00 (Aungier St. 1-005)

Sorry for all of the messing around!


Computer Graphics 7:
Viewing in 3-D

Course Website: http://www.comp.dit.ie/bmacnamee


3
of
23
Contents
In today’s 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
4
of
23
3-D Coordinate Spaces
Remember what we mean by a 3-D
Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

coordinate space
y axis

z
x
Right-Hand
z axis x axis Reference System
5
of
23
Translations In 3-D
To translate a point in three dimensions by
Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

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
6
of
23
Scaling In 3-D

To sale a point in three dimensions by sx, sy


Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

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
7
of
23
Rotations In 3-D
When we performed rotations in two
dimensions we only had the choice of
rotating about the z axis
In the case of three dimensions we have
more options
– Rotate about x – pitch
– Rotate about y – yaw
– Rotate about z - roll
8
of
23
Rotations In 3-D (cont…)
The equations for the three kinds of
Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

rotations in 3-D are as follows:

x’ = x·cosθ - y·sinθ x’ = x x’ = z·sinθ + x·cosθ


y’ = x·sinθ + y·cosθ y’ = y·cosθ - z·sinθ y’ = y
z’ = z z’ = y·sinθ + z·cosθ z’ = z·cosθ - x·sinθ
9
of
23
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
All transformations can y

then be represented
as matrices P
 x
 y
  z
P(x, y, z) =  z x
 
1 z axis x axis
10
of
23
3D Transformation Matrices

1 0 0 dx  sx 0 0 0
0 1 0 dy 0 sy 0 0 Scaling by
Translation by  
dx, dy, dz  0 0 1 dz 0 0 sz 0 sx, sy, sz
   
0 0 0 1 0 0 0 1

1 0 0 0  cosθ 0 sinθ 0 cos θ − sin θ 0 0


0 cos θ − sin θ 0  0 1 0 0  sin θ cos θ 0 0
  
0 sin θ cos θ 0  − sinθ 0 cosθ 0  0 0 1 0
     
0 0 0 1  0 0 0 1  0 0 0 1
Rotate About X-Axis Rotate About Y-Axis Rotate About Z-Axis
Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

of
23
11
Remember The Big Idea
12
of
23
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?


13
of
23
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
Project onto Transform to
coordinate Clip against 2-D device
projection 2-D device
output view volume coordinates
plane coordinates
primitives
14
of
23
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


15
of
23
Types Of Projections (cont…)
For anyone who did engineering or technical
drawing
16
of
23
Parallel Projections
Some examples of parallel projections

Orthographic Projection

Isometric Projection
17
of
23
Isometric Projections
Isometric projections have been used in
computer games from the very early days of
the industry up to today

Q*Bert Sim City Virtual Magic Kingdom


18
of
23
Perspective Projections
Perspective projections are much more
realistic than parallel projections
19
of
23
Perspective Projections
There are a number of different kinds of
Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

perspective views
The most common are one-point and two
point perspectives

Two-Point
Perspective
One Point Perspective
Projection
Projection
20
of
23
Elements Of A Perspective Projection

Virtual
Camera
21
of
23
The Up And Look Vectors

Projection of Up vector The look vector


Look vector
up vector
indicates the direction in
which the camera is
Position
pointing
The up vector
determines how the
camera is rotated
For example, is the camera held vertically or
horizontally
22
of
23
Summary
In today’s 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
23
of
23
Who’s Choosing Graphics?
A couple of quick questions for you:
– Who is choosing graphics as an option?
– Are there any problems with option time-
tabling?
– What do you think of the course so far?
• Is it too fast/slow?
• Is it too easy/hard?
• Is there anything in particular you want to cover?

You might also like