Lect 2
Lect 2
Lecture 2
Transformations
Lecture 2 1
TRANSFORMATIONS.
What is a transformation?
P=T(P)
– Geometric Transformations
• Translation
• Rotation
• scaling
• Linear (preserves parallel lines)
• Non-uniform scales, shears or skews
– Projection (preserves lines)
• Perspective projection
• Parallel projection
– Non-linear (lines become curves)
• Twists, bends, warps, morphs,
3
GEOMETRIC TRANSFORMATION
– Once the models are prepared, we need to place them in
the environment
– Objects are defined in their own local coordinate
system
– We need to translate, rotate and scale them to put them
into the world coordinate system
15/04/16 Lecture 1
2D TRANSLATIONS.
Point P defined as P ( x, y ),
translate to Point P( x, y) a distance d x parallel to x axis, d y parallel to y axis.
x x d x y y d y
Define the column vectors
x x d x
P , P , T
y y dy P’
Now P
P P T
5
2D SCALING FROM THE ORIGIN.
Point P defined as P ( x, y ),
Perform a scale (stretch) to Point P( x, y) by a factor s x along the x axis,
and s y along the y axis.
x s x . x, y s y . y
Define the matrix P’
P
sx 0
S
0 s y
Now
x s x 0 x
P S P or y 0 .
s y y
6
2D ROTATION ABOUT THE ORIGIN.
P’(x’,y’)
P(x,y)
r
r
x
7
2D ROTATION ABOUT THE ORIGIN.
y
P’(x’,y’)
r
P(x,y) x r. cos
y r. sin
y
r
x
x 8
2D ROTATION ABOUT THE ORIGIN.
x r. cos( ) r. cos . cos r. sin . sin
y y r. sin( ) r. cos . sin r. sin . cos
P’(x’,y’)
P(x,y)
r x r. cos
y r. sin
y
r
x
x 9
2D ROTATION ABOUT THE ORIGIN.
x r. cos( ) r. cos . cos r. sin . sin
y r. sin( ) r. cos . sin r. sin . cos
Substituting for r :
x r. cos
y r. sin
Gives us :
x x. cos y. sin
y x. sin y. cos
10
2D ROTATION ABOUT THE ORIGIN.
x x. cos y. sin
y x. sin y. cos
Rewriting in matrix form gives us :
x cos sin x
y sin .
cos y
cos sin
Define the matrix R , P R P
sin cos 11
TRANSFORMATIONS.
Translation.
P=T +P
Scale
P=S P
Rotation x cos sin x
y sin cos . y
P=R P
We would like all transformations to be multiplications so
we can concatenate them
express points in homogenous coordinates.
12
CONCATENATION.
So we expect :
T (d x1 , d y1 ) T (d x 2 , d y 2 ) T (d x1 d x 2 , d y1 d y 2 )
13
CONCATENATION.
0 0 1 0 0 1
Matrix product is variously referred to as compounding,
concatenation, or composition
14
CONCATENATION.
1. T (0,0) I
2. T ( s x , s y ) T (t x , t y ) T ( s x t x , s y t y )
3. T ( s x , s y ) T (t x , t y ) T (t x , t y ) T ( s x , s y )
4. T -1 ( s x , s y ) T ( s x , s y )
17
PROPERTIES OF ROTATION.
R ( 0) I
R ( ) R ( ) R ( )
and
R ( ) R ( ) R ( ) R ( )
But this is only because the axis of rotation
is the same
For 3D rotations, need to be more careful
18