Graphics & Visualization
Chapter 4
Projections and Viewing Transformations
Graphics & Visualization: Principles & Algorithms Chapter 4
Projections and Viewing Transformations Graphics & - - PowerPoint PPT Presentation
Graphics & Visualization Chapter 4 Projections and Viewing Transformations Graphics & Visualization: Principles & Algorithms Chapter 4 Introduction In computer graphics there are: 3D models 2D
Graphics & Visualization: Principles & Algorithms Chapter 4
Graphics & Visualization: Principles & Algorithms Chapter 4 2
3D models 2D output devices (displays and printers)
Must take place at some point in the graphics pipeline Usually after the culling stages and before the rendering stage
Defines the transition from the world coordinate
system (WCS) to canonical screen system (CSS) via the eye coordinate system (ECS)
Specifies the clipping bounds (for frustum culling)
in ECS
Graphics & Visualization: Principles & Algorithms Chapter 4 3
Simplifies a number of operations including culling (e.g. the specification of
the clipping bounds by the user) and projection
Ensures that all objects that survived culling will be defined in a canonical
space (usually [-1,1])
Can easily be scaled to the actual coordinates of any display device or monitor Maintain high floating-point accuracy
Graphics & Visualization: Principles & Algorithms Chapter 4 4
Center of projection Points on the image being projected
Projections are from 3D space onto 2D space The 2D space is referred to as the plane of projection & models the output
device
Graphics & Visualization: Principles & Algorithms Chapter 4 5
Perspective: the distance of the center of projection from the plane of
projection is finite
Parallel: the distance of the center of projection from the plane of
projection is infinite
Graphics & Visualization: Principles & Algorithms Chapter 4 6
ab a b bd b d ac a c cd c d ab a b bd b d
Graphics & Visualization: Principles & Algorithms Chapter 4 7
Center of projection: the pinhole Plane of projection: the image plane (where the image is formed) Creates an inverted image Derive an upright image by placing the image ‘in front’ of the pinhole
Graphics & Visualization: Principles & Algorithms Chapter 4 8
Center of projection is the origin Plane of projection is perpendicular to the
negative z-axis at distance d from the center
and
1 2 1 2
OP P OP P · y y d y y d z z
1 2 1 2 2 2
P P P P OP OP
· d x x z
Graphics & Visualization: Principles & Algorithms Chapter 4 9
1 d d d
PER
P
· · · · 1 x x d y y d z z d z
PER
P
· · · · / · 1 x d x d z y d y d z z z d d z
Graphics & Visualization: Principles & Algorithms Chapter 4 10
The size of the projection of an object is inversely proportional to its distance
from the center of projection
Graphics & Visualization: Principles & Algorithms Chapter 4 11
The direction of projection (a vector) The plane of projection
Orthographic: the direction of projection is normal to the plane
Oblique: the direction of projection is not necessarily normal to
Graphics & Visualization: Principles & Algorithms Chapter 4 12
ORTHO
1 1 1
ORTHO
P
Graphics & Visualization: Principles & Algorithms Chapter 4 13
[ , , ]T
x y z
DOP DOP DOP DOP
·
z z
z z DOP DOP
· · and ·
y x x z z
DOP DOP x x DOP x z y y z DOP DOP
Graphics & Visualization: Principles & Algorithms Chapter 4 14
1 1 ( ) 1
x z y z
DOP DOP DOP DOP
OBLIQUE
P DOP
( )·
OBLIQUE
P P DOP P
Graphics & Visualization: Principles & Algorithms Chapter 3 15
1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 1 1 1 1 C
Graphics & Visualization: Principles & Algorithms Chapter 3 16
1 1 1 1 1 1 1 1 1 1 · · 1 1 1 1 1 2 2 2 2 1 1 1 1 1 2 2 2 2
PER
P C C
1 1 1 1 2 2 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Graphics & Visualization: Principles & Algorithms Chapter 3 17
1 1 1 1 1 1 1 1 10 10 10 10 11 11 11 11 1 1 1 1 1 1 1 1 C
10 10 10 10 10 10 10 10 10 10 · 10 100 100 100 100 110 110 110 110 1 10 10 10 10 11 11 11 11 C
10 10 1 1 11 11 10 10 1 1 11 11 10 10 10 10 10 10 10 10 1 1 1 1 1 1 1 1
Graphics & Visualization: Principles & Algorithms Chapter 3 18
[ , , ]T
x y z
n n n N
Graphics & Visualization: Principles & Algorithms Chapter 3 19
R P
· ( ) ( ) ( )
x y z x y z x y z
N
x n y y n z z
n y n z n x n y n z R P
x y z
c a n x n y n z
, x y z
c c c n n n
PER
P
Graphics & Visualization: Principles & Algorithms Chapter 3 20
cos 1 tan sin 1 ( , ) tan 1
OBLIQUE
P
Graphics & Visualization: Principles & Algorithms Chapter 3 21
[ , , ]T
x y z
DOP DOP DOP DOP
[ , , ]T
x y z
n n n N
( ) T R
N
( ) A N
Graphics & Visualization: Principles & Algorithms Chapter 3 22
( ) T R
, (
1 OBLIQUE OBLIQUE
Graphics & Visualization: Principles & Algorithms Chapter 4 23
the process of coordinate conversion: The clipping boundaries (for frustum culling) in ECS
Stages following VT (e.g. hidden surface elimination) require 3D
information
Graphics & Visualization: Principles & Algorithms Chapter 4 24
The ECS origin E The direction of view The up direction
defines the up direction need not be perpendicular to
up up
Graphics & Visualization: Principles & Algorithms Chapter 4 25
xe is the horizontal axis & increases to the right
ye is the vertical axis & increases upwards
ze-axis points towards the observer (right-handed ECS)
Compute xe- and ye-axes as cross products:
up
e e e e e
e
Graphics & Visualization: Principles & Algorithms Chapter 4 26
i. Establish matrix ii. Pre-multiply all object vertices by it
Translation by
Change of basis (rotational transformation)
WCS ECS
M
[ , , ]
T x y z
E E E E
[ , , ] , [ , , ] and [ , , ]
T T T x y z x y z x y z
a a a b b b c c c
e e e
x y z
1 1 · 1 1 1
x y z x x y z y x y z z
a a a E b b b E c c c E
WCS ECS
M
Graphics & Visualization: Principles & Algorithms Chapter 4 27
Select a region of space (view volume) that will be mapped to CSS
rectangular parallelepiped
can be defined by 2 opposite vertices
xe = l, the left clip plane
xe = r, the right clip plane, (r > l)
ye = b, the bottom clip plane
ye = t, the top clip plane, (t > b)
ze = n, the near clip plane
ze = f , the far clip plane, ( f < n, since the ze axis points toward the observer)
Graphics & Visualization: Principles & Algorithms Chapter 4 28
Translation & Scaling
Map the (l, b, n) values to -1 and (r, t, f) values to 1
2 2 2 ( , , )· ( , , )· 2 2 2 2 2 1 2 2 2 1 · 2 2 2 1 2 1 1 1 r l t b n f r l t b f n r l r l r l r l r l t b t b t b t b t b n f n f f n f n f n
ORTHO ECS CSS
M S T ID
ORTHO s ECS CSS WCS ECS w
Graphics & Visualization: Principles & Algorithms Chapter 4 29
θ , the angle of the field of view in the y-direction aspect, the width to height ratio of a cross section of the pyramid ze = n, the near clipping plane ze = f , the far clipping plane ( f < n)
Graphics & Visualization: Principles & Algorithms Chapter 4 30
Preserve it for hidden surface & other computations in screen space
Simply keeping ze will deform objects
Use a mapping that preserves lines & planes zs = A + B / ze , where A,B are constants
top: | |·tan( ) 2 bottom:
· left:
n b t r t aspect l r
1 d d d
PER
P
Graphics & Visualization: Principles & Algorithms Chapter 4 31
Makes the w-coordinate equal to ze
Must be followed by a division by ze (perspective division)
Clipping boundaries are not affected
Transforms the truncated pyramid into a rectangular parallelepiped :
1 n n n f nf
VT
P
Graphics & Visualization: Principles & Algorithms Chapter 4 32
2 2 2 ( , , )· (0,0, )· 2 2 1 2 1 · · 0 1 2 2 1 1 1 n f r l t b f n r l n n t b n f n f nf f n
PERSP ECS CSS VT
M S T P 2 2 2 1 n r l n t b n f nf f n f n
Graphics & Visualization: Principles & Algorithms Chapter 4 33
· · x y z w
PERSP ECS CSS WCS ECS w
M M X
/ x y w z w
s
X
Graphics & Visualization: Principles & Algorithms Chapter 4 34
2 2
· · 1 1 l ln b bn n n f f n f
VT VT
P P
2 2
· · · · ln n bn n n n f f n n f f S T S T
Graphics & Visualization: Principles & Algorithms Chapter 4 35
1 1 / / 1 1 1 1 n n n f n f n f
Graphics & Visualization: Principles & Algorithms Chapter 4 36
Graphics & Visualization: Principles & Algorithms Chapter 4 37
ze = n0, the near clipping plane (as before) ze = f0, the far clipping plane, f0 < n0 (as before) ye = b0, the ye-coordinate of the bottom clipping plane at its
intersection with the near clipping plane
ye = t0, the ye-coordinate of the top clipping plane at its intersection
with the near clipping plane
xe = l0, the xe-coordinate of the left clipping plane at its intersection
with the near clipping plane
xe = r0, the xe-coordinate of the right clipping plane at its intersection
with the near clipping plane
Graphics & Visualization: Principles & Algorithms Chapter 4 38
transformation on the xy-plane
Take the shear on the y-coordinate: map the midpoint of t0b0 to 0
Similarly for the xe shear factor:
1 1 1 1 A B
xy
SH
· 2 2 b t b t B n B n
2 l r A n
1 2 1 2 1 1 l r n b t n
NON SYM
SH
Graphics & Visualization: Principles & Algorithms Chapter 4 39
2 2 2 2 n n f f l r l r l l r r b t b t b b t t
PERSP ECS CSS
M
2 2 2 1 n r l n t b n f n f f n f n
PERSP ECS CSS
M
PERSP ECS CSS
M
Graphics & Visualization: Principles & Algorithms Chapter 4 40
2 1 2 2 1 · · 2 2 1 1 1 n l r r l n n b t t b n n f nf f n f n
PERSP NON SYM PERSP ECS CSS ECS CSS NON SYM
M M SH 2 2 2 1 n l r r l r l n b t t b t b n f nf f n f n
Graphics & Visualization: Principles & Algorithms Chapter 4 41
is not sufficient
Direction of projection must be taken into account
The 6 parameters used for the non-symmetrical pyramid (n0, f0, l0, r0, b0, t0)
The direction of projection vector
1. Translate the view volume so that (l0, b0, n0)-point moves to the ECS origin 2. Perform a shear in the xy-plane
ORTHO ECS CSS
M
DOP
Graphics & Visualization: Principles & Algorithms Chapter 4 42
Shear the (DOPy) coordinate to 0:
Similarly for the x-shear factor:
[ , , ]T
x y z
DOP DOP DOP DOP
·
y y z z
DOP DOP B DOP B DOP
x z
DOP A DOP
1 1 1 1 · · 0 1 1 1 1
x z y z
DOP DOP l DOP b DOP n
PARALLEL PARALLEL
SH T
PARALLEL ORTHO ECS CSS ECS CSS PARALLEL PARALLEL
Graphics & Visualization: Principles & Algorithms Chapter 4 43
Eliminates primitives (parts or whole) that lie outside the view volume(frustum)
Is implemented by 3D clipping algorithms
In perspective projection, objects behind the center of projection E would appear upside-down (no sufficient information in clipping)
Avoids possible perspective division by 0
The near and far clipping planes limit the depth range & enable the optimal allocation of the bits of the depth buffer
PERSP ECS CSS
ORTHO ECS CSS
M
Graphics & Visualization: Principles & Algorithms Chapter 4 44
[xmin, ymin]T and [xmax, ymax]T in pixel coordinates
[xmin, ymin, zmin]T and [xmax, ymax, zmax]T to maintain the z-coordinate
1 2 2 2 2 1 · 2 2 2 2 1 2 2 1 1
min max max min max min min max min max max min max min min max min max max min max min
x x x x x x x x y y y y y y y y z z z z z z
VIEWPORT CSS VCS
M 2 2 1
min max
z z