Professional Documents
Culture Documents
2D Transformations
2D Transformations
World Coordinates
Translate
Rotate
Scale
Viewport Transforms
Putting it all together
Transformations
Rigid Body Transformations - transformations that do
not change the object.
Translate
If you translate a rectangle, it is still a rectangle
Scale
If you scale a rectangle, it is still a rectangle
Rotate
If you rotate a rectangle, it is still a rectangle
Vertices
We have always represented vertices as
(x,y)
An alternate method is:
x
( x, y )
y
Example:
2.1
(2.1,4.8)
4.8
Matrix * Vector
x' a b x
y ' c d y
x' ax by
y ' cx dy
1 0
I
0
1
x' a b c x
y ' d e f y
z ' g h i z
x' ax by cz
y ' dx ey fz
z ' gx hy iz
1 0 0
I 0 1 0
0 0 1
Matrix * Matrix
a b
x y
A
,B
c
d
z
w
ax bz ay bw
A* B
cx
dz
cy
dw
a b 1 0
?
0 1
c
d
Practice
2 3
2
A
,X
1 5
3
AX ?
2 3
0.5 1
A
,B
1
5
3
2
.
5
A* B ?
A* I ?
Translation
Translation - repositioning an object along a
straight-line path (the translation
distances) from one coordinate location to
another.
(x,y)
(tx,ty)
(x,y)
Translation
Given:
We want:
Matrix form:
P ( x, y )
T (t x , t y )
x' x t x
y' y t y
P (3.7,4.1)
T (7.1,8.2)
x ' 3 . 7 7 .1
y ' 4 .1 8 .2
Translation Examples
P=(2,4), T=(-1,14), P=(?,?)
P=(8.6,-1), T=(0.4,-0.2), P=(?,?)
P=(0,0), T=(1,0), P=(?,?)
(tx,ty)
(x,y)
(tx,ty)
(x,y)
Recall
A point is a position specified with
coordinate values in some reference frame.
We usually label a point in this reference
point as the origin.
All points in the reference frame are given
with respect to the origin.
Applying to Triangles
(tx,ty)
Scale
Scale - Alters the size of an object.
Scales about a fixed point
(x,y)
(x,y)
Scale
Given:
We want:
Matrix
P ( x, y )
S (sx , s y )
P (1.4,2.2)
S (3,3)
x' s x x
x' 3 *1.4
y ' 3 * 2.2
y' s y y
x' s x
y ' 0
form:
P' S P
x' 3 0 1.4
y ' 0 3 2.2
0 x
s y y x' 4.2
y ' 6.6
Non-Uniform/Differential Scalin
(x,y)
(x,y)
S=(1,2)
Rotation
Rotation - repositions an object along a
circular path.
Rotation requires an and a pivot point
Rotation
P ( x, y )
R ( )
x r cos
y r sin
x' r cos( )
y ' r cos( )
sin x
cos y
Example
P=(4,4)
=45 degrees
Translate (1.2,0.3)
Translate (1.2,0.3)
Rotations
V(-0.6,0) V(0,-0.6) V(0.6,0.6)
Rotate -30 degrees
V(0,0.6) V(0.3,0.9) V(0,1.2)
Combining Transformations
Q: How do we
specify each
transformation?
Specifying 2D Transformations
Translation
T(tx, ty)
Translation distances
Scale
S(sx,sy)
Scale factors
Rotation
R()
Rotation angle
Combining Transformations
Using translate, rotation, and scale, how do
we get:
Combining Transformations
Note there are two ways to combine rotation
and translation. Why?
P' P T
P' R P
P" P 'T
x' x t x
R( )
y' y t y
x" x' cos y ' sin
y" x' sin y ' cos
Combining them
We must do each step in turn. First we
rotate the points, then we translate, etc.
Since we can represent the transformations
by matrices, why dont we just combine
them?
P' P T
P' R P
P' S P
s x 0 0
s
0
x
S s x , s y
0
s
0
y
0
s
y
0 0 1
cos
R
sin
cos
sin
sin
cos
0
sin
cos
0
0
0
1
Homogenous Coordinates
We need to do something to the vertices
By increasing the dimensionality of the
problem we can transform the addition
component of Translation into
multiplication.
xh
6
h
2
4
6
xh
x
3 14
y h 4
P yh y Ex. 2, Ex. 14 7
7
h 2
2
y h
1
2 2
h
h
2
Homogenous Coordinates
Homogenous Coordinates - term used in
mathematics to refer to the effect of this
representation on Cartesian equations. Converting
a pt(x,y) and f(x,y)=0 -> (xh,yh,h) then in
homogenous equations mean (v*xh,v*yh,v*h) can
be factored out.
What you should get: By expressing the
transformations with homogenous equations and
coordinates, all transformations can be expressed
as matrix multiplications.
T t x , t y y ' 0 1 t y y
y ' t y y 1 0 0 1 1
P T t x , t y P P T t x , t y P
x' s x
x' s x 0 x
S s x , s y
y ' 0
y ' 0 s y y 1 0
P S s x , s y P P S s x , s y P
0
sy
0
x' cos
x' cos sin x
R
y ' sin
0 x
0 y
1 1
sin
cos
0
0 x
0 y
1 1
Combining Transformations
P' A P, P" B P' P" A B P
P(3,4), T (0.4641,2), R(60)
x' 1 0 t x x
y ' 0 1 t y
y
1 0 0 1 1
x" cos sin
y" sin cos
1 0
0
x" cos sin
y" sin cos
1 0
0
0 x '
0 y '
1 1
0 1 0 t x x'
0 0 1 t y y '
1 0 0 1 1
Coordinate Systems
Object Coordinates
World Coordinates
Eye Coordinates
Object Coordinates
World Coordinates
Screen Coordinates
Coordinate Hierarchy
Screen Coordinates
Transformation
World->Screen
World Coordinates
Transformation
Object #1 ->
World
Transformation
Object #2 ->
World
Transformation
Object #3 ->
World
Object #1
Object Coordinates
Object #2
Object Coordinates
Object #3
Object Coordinates
Transformation Hierarchies
For example:
Transformation Hierarchies
Lets examine:
Transformation Hierarchies
What is a better way?
Transformation Hierarchies
What is a better way?
Transformation Hierarchies
We can have transformations be
in relation to each other
World Coordinates
Transformation
Green -> World
Green
Object's Coordinates
Transformation
Red -> Green
Red
Object Coordinates
Transformation
Blue -> Red
Blue
Object Coordinates