transformations: projection cs 445/645 introduction to computer graphics david luebke, spring 2003
DESCRIPTION
David Luebke 3 1/24/2016 Admin ● Assn 1 due… now ■ Any issues?TRANSCRIPT
Transformations: Projection
CS 445/645Introduction to Computer Graphics
David Luebke, Spring 2003
David Luebke 2 05/03/23
Admin
● Assn 1 due…
David Luebke 3 05/03/23
Admin
● Assn 1 due… now■ Any issues?
David Luebke 4 05/03/23
Recap: 3-D Rotation Matrices
● An arbitrary rotation about A can be formed by compositing several canonical rotations together
● We can express each rotation as a matrix● Compositing transforms == multiplying matrices● Thus we can express the final rotation as the product
of canonical rotation matrices● Thus we can express the final rotation with a single
matrix!
David Luebke 5 05/03/23
Recap: Compositing Matrices
● We have the following matrices:p: The point to be rotated about A by Ry : Rotate about Y by
Rx : Rotate about X by
Rz : Rotate about Z by
Rx -1: Undo rotation about X by
Ry-1
: Undo rotation about Y by ● Thus:
p’ = Ry-1 Rx
-1 Rz Rx Ry p
David Luebke 6 05/03/23
Recap: Rotation Matrices
● Rotation matrix is orthogonal■ Columns/rows linearly independent■ Columns/rows sum to 1
● The inverse of an orthogonal matrix is its transpose:
jfciebhda
jihfedcba
jihfedcba T1
David Luebke 7 05/03/23
Recap:Homogeneous Coordinates
● Homogeneous coordinates: represent coordinates in 3 dimensions with a 4-vector
(Note that typically w = 1 in object coordinates)
wzyx
wzwywx
zyx
1///
),,(
David Luebke 8 05/03/23
Recap:Homogeneous Coordinates
● Homogeneous coordinates seem unintuitive, but they make graphics operations much easier
● Our transformation matrices are now 4x4:
10000)cos()sin(00)sin()cos(00001
xR
David Luebke 9 05/03/23
Recap:Homogeneous Coordinates
● Homogeneous coordinates seem unintuitive, but they make graphics operations much easier
● Our transformation matrices are now 4x4:
10000)cos(0)sin(00100)sin(0)cos(
yR
David Luebke 10 05/03/23
Recap:Homogeneous Coordinates
● Homogeneous coordinates seem unintuitive, but they make graphics operations much easier
● Our transformation matrices are now 4x4:
1000010000)cos()sin(00)sin()cos(
zR
David Luebke 11 05/03/23
Recap:Homogeneous Coordinates
● Homogeneous coordinates seem unintuitive, but they make graphics operations much easier
● Our transformation matrices are now 4x4:
1000000000000
z
y
x
SS
S
S
David Luebke 12 05/03/23
Recap:Homogeneous Coordinates
● Homogeneous coordinates seem unintuitive, but they make graphics operations much easier
● Our transformation matrices are now 4x4:
1 0 00 1 00 0 10 0 0 1
x
y
z
TTT
T
David Luebke 13 05/03/23
Recap:Translation Matrices
● Now that we can represent translation as a matrix, we can composite it with other transformations
● Ex: rotate 90° about X, then 10 units down Z:
wzyx
wzyx
10000)90cos()90sin(00)90sin()90cos(00001
10001010000100001
''''
David Luebke 14 05/03/23
Recap:Translation Matrices
● Now that we can represent translation as a matrix, we can composite it with other transformations
● Ex: rotate 90° about X, then 10 units down Z:
wzyx
wzyx
1000001001000001
10001010000100001
''''
David Luebke 15 05/03/23
Recap:Translation Matrices
● Now that we can represent translation as a matrix, we can composite it with other transformations
● Ex: rotate 90° about X, then 10 units down Z:
wzyx
wzyx
10001001001000001
''''
David Luebke 16 05/03/23
Recap:Translation Matrices
● Now that we can represent translation as a matrix, we can composite it with other transformations
● Ex: rotate 90° about X, then 10 units down Z:
wy
zx
wzyx
10''''
David Luebke 17 05/03/23
More On Homogeneous Coords
● What effect does the following matrix have?
● Conceptually, the fourth coordinate w is a bit like a scale factor
wzyx
wzyx
10000010000100001
''''
David Luebke 18 05/03/23
More On Homogeneous Coords
● Intuitively:■ The w coordinate of a homogeneous point is typically 1■ Decreasing w makes the point “bigger”, meaning further
from the origin■ Homogeneous points with w = 0 are thus “points at
infinity”, meaning infinitely far away in some direction. (What direction?)
■ To help illustrate this, imagine subtracting two homogeneous points
David Luebke 19 05/03/23
Perspective Projection
● In the real world, objects exhibit perspective foreshortening: distant objects appear smaller
● The basic situation:
David Luebke 20 05/03/23
Perspective Projection
● When we do 3-D graphics, we think of the screen as a 2-D window onto the 3-D world:
How tall shouldthis bunny be?
David Luebke 21 05/03/23
Perspective Projection
● The geometry of the situation is that of similar triangles. View from above:
● What is x’?
P (x, y, z)X
Z
Viewplane
d
(0,0,0) x’ = ?
David Luebke 22 05/03/23
Perspective Projection
● Desired result for a point [x, y, z, 1]T projected onto the view plane:
● What could a matrix look like to do this?
dzdz
yz
ydydz
xz
xdx
zy
dy
zx
dx
,','
','
David Luebke 23 05/03/23
A Perspective Projection Matrix
● Answer:
0100010000100001
d
M eperspectiv
David Luebke 24 05/03/23
A Perspective Projection Matrix
● Example:
● Or, in 3-D coordinates:
10100010000100001
zyx
ddzzyx
d
dzy
dzx ,,
David Luebke 25 05/03/23
A Perspective Projection Matrix
● OpenGL’s gluPerspective() command generates a slightly more complicated matrix:
■ Can you figure out what this matrix does?
2cotwhere
0100
200
000
000
y
farnear
nearfar
farnear
nearfar
fovf
ZZZZ
ZZZΖ
faspect
f
David Luebke 26 05/03/23
Projection Matrices
● Now that we can express perspective foreshortening as a matrix, we can composite it onto our other matrices with the usual matrix multiplication
● End result: can create a single matrix encapsulating modeling, viewing, and projection transforms■ Though you will recall that in practice OpenGL separates
the modelview from projection matrix (why?)