2. 2D Transformations
• World Coordinates
• Translate
• Rotate
• Scale
• Viewport Transforms
• Putting it all together
3. 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
4. Vertices
• We have always represented vertices as
(x,y)
• An alternate method is:
• Example:
=
y
x
yx ),(
=
8.4
1.2
)8.4,1.2(
8. Translation
• Translation - repositioning an object along a
straight-line path (the translation
distances) from one coordinate location to
another.
(x,y)
(x’,y’)
(tx,ty)
9. Translation
• Given:
• We want:
• Matrix form:
TPP
t
t
y
x
y
x
tyy
txx
ttT
yxP
y
x
y
x
yx
+=
+
=
+=
+=
=
=
'
'
'
'
'
),(
),(
1.4'
4.3'
2.8
1.7
1.4
7.3
'
'
2.81.4'
1.77.3'
)2.8,1.7(
)1.4,7.3(
=
=
+
−
−
=
+−=
+−=
=
−−=
y
x
y
x
y
x
T
P
11. Which one is it?
(x,y)
(x’,y’)
(tx,ty)
(x,y)
(tx,ty)
12. 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.
28. 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 don’t we just combine
them?
PSP
PRP
TPP
•=
•=
+=
'
'
'
29. 2x2 -> 3x3 Matrices
• We can combine transformations by
expanding from 2x2 to 3x3 matrices.
( )
( )
( )
−
=
−
=
=
=
=
+
=
100
0cossin
0sincos
cossin
sincos
100
00
00
0
0
,
100
10
01
,
θθ
θθ
θθ
θθ
θR
s
s
s
s
ssS
t
t
t
t
y
x
ttT
y
x
y
x
yx
y
x
y
x
yx
30. 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.
=
=
=
→
→
=
=
=
→
=
2
2
2
14
7
2
6
3
2
14
6
7
3
.,
1
2
4
2
4
. ExEx
h
h
h
y
y
h
x
x
h
y
x
y
x
P h
h
h
h
31. 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.
32. Final Transformations -
Compare Equations
( )
( ) ( )
( )
( ) ( )
( )
( ) ( ) PRPPRP
y
x
y
x
y
x
y
x
R
PssSPPssSP
y
x
s
s
y
x
y
x
s
s
y
x
ssS
PttTPPttTP
y
x
t
t
y
x
y
x
t
t
y
x
ttT
yxyx
y
x
y
x
yx
yxyx
y
x
y
x
yx
•=→•=
−
=
→
−
=
=
•=→•=
=
→
=
=
•=→+=
=
→
+
=
=
θθ
θθ
θθ
θθ
θθ
θ
1100
0cossin
0sincos
1
'
'
cossin
sincos
'
'
,,
1100
00
00
1
'
'
0
0
'
'
,
,,
1100
10
01
1
'
'
'
'
,
33. Combining Transformations
−
=
−
=
=
−
••=→•=•=
1
'
'
100
10
01
100
0cossin
0sincos
1
"
"
1
'
'
100
0cossin
0sincos
1
"
"
1100
10
01
1
'
'
)60(),2,4641.0(),4,3(
"'",'
y
x
t
t
y
x
y
x
y
x
y
x
t
t
y
x
RTP
PBAPPBPPAP
y
x
y
x
θθ
θθ
θθ
θθ
−
=
−
=
+
−−
=
1100
cossin
sincos
1
"
"
1100
0cossin
0sincos
100
10
01
1
"
"
1100
cossincossin
sincossincos
1
"
"
y
x
t
t
y
x
y
x
t
t
y
x
y
x
tt
tt
y
x
y
x
y
x
yx
yx
θθ
θθ
θθ
θθ
θθθθ
θθθθ
40. Coordinate Hierarchy
O b je c t # 1
O b je c t C o o r d in a t e s
T r a n s f o r m a t io n
O b je c t # 1 ->
W o r ld
O b je c t # 2
O b je c t C o o r d in a t e s
T r a n s f o r m a t io n
O b je c t # 2 - >
W o r ld
O b je c t # 3
O b je c t C o o r d in a t e s
T r a n s f o r m a t io n
O b je c t # 3 ->
W o r ld
W o r ld C o o r d in a t e s
T r a n s f o r m a t io n
W o r ld - > S c r e e n
S c r e e n C o o r d in a t e s
46. Transformation Hierarchies
• We can have transformations be
in relation to each other
B lu e
O b je c t C o o r d in a te s
T ra n s fo r m a tio n
B lu e -> R e d
R e d
O b je c t C o o r d in a te s
T ra n s fo r m a tio n
R e d - > G r e e n
G r e e n
O b je c t 's C o o r d in a te s
T ra n s fo r m a tio n
G re e n -> W o r ld
W o r ld C o o r d in a t e s