Rotate Graphics
Rotate Graphics
Rotate Graphics
Viewing Transforms
Administrivia
Assignment 2 is online - get started this
weekend
Midterm will be before reading break - Oct 19
Today’s reading material: FvD, Chapter 6
Translations
Moving an object is called a translation. We translate a point by adding to
the x and y coordinates, respectively, the amount the point should be
shifted in the x and y directions. We translate an object by translating
each vertex in the object.
ty
tx
hnew
hold
wold wnew
sx=wnew/wold sy=hnew/hold
xnew = sxxold ynew = syyold
Rotation about the Origin
(x1,y1)
From the illustration we know that:
r
sin (A + B) = y2/r cos (A + B) = x2/r B
Scale:
xnew = sxxold sx 0 x sx x
0
ynew = syyold
s y y s y y
Rotation:
x2 = x1cos - y1sin
cos sin x x cos y sin
y2 = x1sin + y1cos
sin
cos y x sin y cos
Translation:
xnew = xold + tx
t x x x t x
ynew = yold + ty
t y t
y y y
Homogeneous Coordinates
In order to represent a translation as a matrix multiplication operation we
use 3 x 3 matrices and pad our points to become 3 x 1 matrices. This
coordinate system (using three values to represent a 2D point) is called
homogeneous coordinates.
x cos sin 0
P( x , y ) y R sin cos 0
1 0 0 1
sx 0 0 1 0 t x
S x, y 0 sy 0 Tx , y 0 1 t y
0 0 1 0 0 1
Composite Transformations
Before After
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
1 0 2 2 0 0 1 0 2 2 0 2 0 1 2 3 4 5 6 7 8 9 10
0 1 1 0 1 0 0 1 1 0 1 0
0 0 1 0 0 1 0 0 1 0 0 1
T2,1 S 2,1 T 2, 1 C
1 0 x cos sin 0 1 0 x
C 0 1 y sin cos 0 0 1 y
0 0 1 0 0 1 0 0 1
Tx , y R T x , y
Shears
1 0 0 1 b 0
a 1 0 0 1 0
0 0 1 0 0 1
Reflections
1 0 0 1 0 0
0 1 0 0 1 0
0 0 1 0 0 1
More Reflections
1 0 0
0 1 0
?
0 0 1
?
Transformations as a change in
coordinate system
All transformations we have looked at involve
transforming points in a fixed coordinate
system (CS).
Can also think of them as a transformation of
the CS itself
Transforming the CS - examples
Translate(4,4)
Rotate(180°)
Why transform the CS?
Objects often defined in a “natural” or
“convenient” CS
House drawn in a CS
that’s been translated,
rotated, and scaled
M = Sx,y Rd Tx,y
Projecting 3-D into 2-D
Rotations and translations are sufficient to
convert 3D to 2D
Camera is at origin
Camera is looking along negative z-axis
Camera’s ‘up’ is aligned with y-axis
2 Basic Steps
Align the two coordinate frames by rotation
2 Basic Steps
Translate to align origins
Creating Camera Coordinate
Space
Specify a point where the camera is located
in world space, the eye point
Specify a point in world space that we wish to
become the center of view, the lookat point
Specify a vector in world
space that we wish to
point up in camera
image, the up vector
Intuitive camera
movement
Constructing Viewing
Transformation, V
Create a vector from eye-point to lookat-point
Therefore, M-1 = MT
Compositing Vectors to Form V
Therefore, rotation component of viewing
transformation is just transpose of computed
vectors
Compositing Vectors to Form V
Translation component too
Multiply it through
Final Viewing Transformation, V
To transform vertices, use this matrix:
y’ = ?
Z (0,0,0)
What is y’? d
Perspective Projection
Desired result for a point [x, y, z, 1]T projected
onto the view plane:
x' x y' y
,
d z d z
dx x dy y
x' , y' , zd
z z d z z d