Upload
joseph-white
View
227
Download
5
Embed Size (px)
Citation preview
1GR2-00
GR2Advanced Computer
GraphicsAGR
GR2Advanced Computer
GraphicsAGR
Lecture 3Viewing - Projections
2GR2-00
ViewingViewing
Graphics display devices are 2D rectangular screens
Hence we need to understand how to transform our 3D world to a 2D surface
This involves:– selecting the observer position observer position (or
camera position)– selecting the view plane view plane (or camera film
plane)– selecting the type of projectionprojection
3GR2-00
Perspective ProjectionsPerspective Projections
There are two types of projection: perspectiveperspective and parallelparallel
In a perspectiveperspective projection, object positions are projected onto the view plane along lines which converge at the observerP1
P2
P1’
P2’
view plane
camera
4GR2-00
Parallel ProjectionParallel Projection
In a parallel projection, the observer position is at an infinite distance, so the projection lines are parallelP1
P2
view plane
5GR2-00
Perspective and Parallel Projection
Perspective and Parallel Projection
Parallel projection preserves the relative proportions of objects, but does not give a realistic view
Perspective projection gives realistic views, but does not preserve proportions– Projections of distant objects are
smaller than projections of objects of the same size which are closer to the view plane
6GR2-00
Perspective and Parallel Projection
Perspective and Parallel Projection
perspective parallel
7GR2-00
PuzzlePuzzle
8GR2-00
Another ExampleAnother Example
9GR2-00
Viewing Coordinate System
Viewing Coordinate System
Viewing is easier if we work in a viewing co-ordinate systemviewing co-ordinate system, where the observer or camera position is on the z-axis, looking along the negative z-direction
xV
yV
zV
Camera is positioned at:(0 , 0, zC)
10GR2-00
View PlaneView Plane
We assume the view plane is perpendicular to the viewing direction
The view planeis positioned at:(0, 0, zVP)
Let d = zC - zVP be thedistance between thecamera and the plane
xv
yv
zv
11GR2-00
Perspective Projection Calculation
Perspective Projection Calculation
xv
yv
zv
zVview plane
Q
camerayV
zCzQ zVP
looking along x-axis
12GR2-00
Perspective Projection Calculation
Perspective Projection Calculation
zVview plane
Q
camerayV
P
By similar triangles, yP / yQ = (zC - zVP) / (zC - zQ)and soyP = yQ * (zC - zVP) / (zC - zQ)oryP = yQ * d / (zC - zQ)
zCzQ zVP
xP likewise
13GR2-00
Using Matrices and Homogeneous Coordinates
Using Matrices and Homogeneous Coordinates
We can express the perspective transformation in matrix form
Point Q in homogeneous coordinates is (xQ, yQ, zQ, 1)
We shall generate a point H in homogeneous coordinates (xH, yH, zH, wH), where wH is not 1
But the point (xH/wH, yH/wH, zH/wH, 1) is the same as H in homogeneous space
This gives us the point P in 3D space, ie xP = xH/wH, sim’ly for yP
14GR2-00
Transformation Matrix for Perspective
Transformation Matrix for Perspective
1 0 0 0
0 1 0 0
0 0 -zVP/d zVPzC/d
0 0 -1/d zC/d
xQ
yQ
zQ
1
xH
yH
zH
wH
=
Then xP = xH / wH
iexP = xH / ( (zC - zQ) / d )iexP = xQ / ( (zC - zQ) / d )
yP likewise
15GR2-00
ExercisesExercises
There are two special cases which you can now derive:– camera at the origin (zC = 0)
– view plane at the origin (zVP = 0) Follow through the operations
just described for these two cases, and write down the transformation matrices
16GR2-00
Note for LaterNote for Later
The original z co-ordinate of points is retained – we need relative depth in the scene
in order to sort out which faces are visible to the camera
17GR2-00
Vanishing PointsVanishing Points
When a 3D object is projected onto a view plane using perspective, parallel lines in object NOT parallel to the view plane converge to a vanishing vanishing pointpoint
view plane
vanishing point
one-pointperspectiveprojectionof cube
18GR2-00
One- and Two-Point Perspective DrawingOne- and Two-Point Perspective Drawing
19GR2-00
One-point PerspectiveOne-point Perspective
Said to be the firstpainting in perspective
This is:Trinity with the Virgin,St John and Donors,by Mastaccio in 1427
20GR2-00
Two-point PerspectiveTwo-point Perspective
EdwardHopperLighthouseat Two Lights
-seewww.postershop.com
21GR2-00
Parallel Projection - Two types
Parallel Projection - Two types
OrthographicOrthographic parallel projection has view plane perpendicular to direction of projection
ObliqueOblique parallel projection has view plane at an oblique angle to direction of projection
P1
P2
view plane
P1
P2
view plane
We shall only consider orthographic projectionorthographic projection
22GR2-00
Parallel Projection Calculation
Parallel Projection Calculation
xv
yv
zv
zVview plane
Q
yV
zQ zVP
looking along x-axis
23GR2-00
Parallel Projection Calculation
Parallel Projection Calculation
zVview plane
Q
yV
P
yP = yQ
and similarly xP = xQ
24GR2-00
Parallel Projection Calculation
Parallel Projection Calculation
So this is much easier than perspective!– xP = xQ
– yP = yQ
– zP = zVP
The transformation matrix is simply1 0 0 0
0 1 0 00 0 zVP/zQ 00 0 0 1
25GR2-00
View Volumes - View Window
View Volumes - View Window
Type of lens in a camera is one factor which determines how much of the view is captured– wide angle lens captures more than
regular lens Analogy in computer graphics is the
view windowview window, a rectangle in the view plane
xv
yv
zv
view window
26GR2-00
View Volume - Front and Back Planes
View Volume - Front and Back Planes
We will also typically want to limit the view in the zV direction
We define two planes, each parallel to the view plane, to achieve this– front plane (or near plane)– back plane (or far plane)
front planeback plane
zV
27GR2-00
View Frustum - Perspective Projection
View Frustum - Perspective Projection
view window
backplane
frontplane
camera
view frustum
zV
28GR2-00
View Volume - Parallel Projection
View Volume - Parallel Projection
view window
backplane
frontplane
zV
view volume
29GR2-00
View VolumeView Volume
The front and back planes act as important clipping planesclipping planes
Can be used to select part of a scene we want to view
Front plane Front plane important in perspective to remove near objects which will swamp picture