Documente Academic
Documente Profesional
Documente Cultură
Computer Graphics
CS 445 / 645
Angel: Interactive Computer
Graphics
Lecture 11
Chapter 7: Camera
Transformations
Announcements
Midterm is one week from today
Old tests will be available
Detailed list of chapter coverage made available
Homework on Thursday to sample coverage
Material covers up to todays class
Taxonomy of Projections
Taxonomy of Projections
Parallel Projection
Center of projection is at infinity
Direction of projection (DOP) same for all points
View
Plane
DOP
Orthographic Projections
DOP perpendicular to view plane
Front
Top
Side
Oblique Projections
DOP not perpendicular to view plane
63.4
45
Cavalier
o
(DOP = 45 )
tan() = 1
Cabinet
o
(DOP = 63.4 )
tan() = 2
H&B
Oblique Parallel-Projection
Oblique Parallel-Projection
Transformation Matrix
x p x ( zvp z )
V px
V px
V pz
V py
V pz
1 0
Vp
0 1 V
pz
1
0 0
0 0
0
zvp
zvp
HB Matrix 7-13
V px
V pz
V py
V pz
0
1
Orthographic Projection
Simple Orthographic
Transformation
right = 20 m
top=20 m
(max pixx, max pixy)
(height in pixels)
bottom=10 m
(0, 0)
(width in pixels)
Perspective Transformation
First discovered by Donatello, Brunelleschi, and DaVinci
during Renaissance
Objects closer to viewer look larger
Parallel lines appear to converge to single point
Perspective Projection
How many vanishing points?
3-Point
Perspective
2-Point
Perspective
1-Point
Perspective
Angel Figure 5.10
Perspective Projection
In the real world, objects exhibit perspective
foreshortening: distant objects appear
smaller
The basic situation:
Perspective Projection
When we do 3-D graphics, we think of the
screen as a 2-D window onto the 3-D world:
Perspective Projection
The geometry of the situation is that of similar triangles. View
from above:
View
plane
x = ?
(0,0,0)
What is x ?
P (x, y, z)
Perspective Projection
Desired result for a point [x, y, z, 1]T projected onto the
view plane:
x' x
,
d
z
dx
x
x'
,
z
z d
y' y
d
z
dy
y
y'
,
z
z d
zd
0 0
1
0
0 1
0 1d
0
0
0
x
1
y
0
0
z
z d
0
0 0
1
0
0 1
0 1d
0
0
x
y
z
1
,
z d
y
,
z d
Projection Matrices
Now that we can express perspective
foreshortening as a matrix, we can compose it
onto our other matrices with the usual matrix
multiplication
End result: a single matrix encapsulating
modeling, viewing, and projection transforms
Parallel projection
+ Good for exact measurements
+ Parallel lines remain parallel
Angles are not (in general) preserved
Less realistic looking
Classical Projections
Viewing in OpenGL
OpenGL has multiple matrix stacks - transformation functions rightmultiply the top of the stack
Two most important stacks: GL_MODELVIEW and GL_PROJECTION
Points get multiplied by the modelview matrix first, and then the
projection matrix
GL_MODELVIEW: Object->Camera
GL_PROJECTION: Camera->Screen
glViewport(0,0,w,h): Screen->Device
OpenGL Example
void SetUpViewing()
{
// The viewport isnt a matrix, its just state...
glViewport( 0, 0, window_width, window_height );
// Set up camera->screen transformation first
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( 60, 1, 1, 1000 ); // fov, aspect, near, far
// Set up the model->camera transformation
glMatrixMode( GL_MODELVIEW );
gluLookAt( 3, 3, 2,
// eye point
0, 0, 0,
// look at point
0, 0, 1 ); // up vector
glRotatef( theta, 0, 0, 1 ); // rotate the model
glScalef( zoom, zoom, zoom ); // scale the model
}
A 3D Scene
Notice the presence of
the camera, the
projection plane, and
the world
coordinate axes
Viewing transformations define how to acquire the image
on the projection plane
Viewing Transformations
Create a camera-centered view
Camera is at origin
Camera is looking along negative z-axis
Cameras up is aligned with y-axis
2 Basic Steps
Align the two coordinate frames by rotation
2 Basic Steps
Translate to align origins
Constructing Viewing
Transformation, V
Create a vector from eye-point to lookat-point
Constructing Viewing
Transformation, V
Construct another important vector from the
cross product of the lookat-vector and the vupvector
This vector, when normalized, should align with
[1, 0, 0]T Why?
Constructing Viewing
Transformation, V
One more vector to define
This vector, when normalized, should align with [0, 1, 0] T
Therefore, M-1 = MT
Multiply it through