Daroko blog-where IT leaners apply their Skills
 Do Not just learn computer graphics an close your computer browser
tab and go away..
 APPLY them in real business,
 Visit Daroko blog for real IT skills applications,androind,
Computer graphics,Networking,Programming,IT jobs Types, IT
news and applications,blogging,Builing a website, IT companies
and how you can form yours, Technology news and very many
More IT related subject.
 -simply Google: Daroko
blog(www.professionalbloggertricks.com)
CS580 Computer Graphics
2D Transformations2D Transformations
Sung Yong Shin
Dept. of Computer Science
KAIST
Daroko blog
Daroko blog
Outline
1. Preliminary
2. Basic 2D Transformations
3. Homogeneous Coordinate system
4. Composite Transformations
5. Reflection and Shearing
per-vertex operations &
primitive assembly
rasterization frame buffer
texture assembly
display lists
evaluators
pixel operations
per-fragment
operations
geometric
data
pixel
data
OpenGL Rendering Pipeline
Window-to-viewport
mapping
2. Basic Transformations
translation
scaling
rotation
(absolute) transformation
relative transformation












=





′
′
=′
=′
y
x
S
S
y
x
ySy
xSx
y
x
y
x
0
0
x
y
( , )T
F Fx y : fixed point
1p
2p
3p
y
x
( , )T
F Fx y
Scaling
( , )T
x y
( ', ')T
x y
(a)
(b)
Non-uniform scaling
θθ
θφθφ
θφ
sincos
sinsincoscos
)cos(
yx
rr
rx
−=
−=
+=′
θθ sincos xyy +=′
Similarly,
( , )T
x y
( , )T
x y′ ′
r
θ
φ
r
φ
φ
sin
cos
ry
rx
=
=
Rotation
θθ
θθ
sincos
sincos
xyy
yxx
+=′
−=′











 −
=





′
′
y
x
y
x
θθ
θθ
cossin
sincos
( , )T
R Rx y
( , )T
x y
( , )T
x y′ ′
r
θ
φ
r
θ
( , )T
x y
( , )T
x y′ ′
r
φ
r
( , )T
R Rx y
: Pivot point
















=





′
′
+=′
+=′
1
10
01
y
x
T
T
y
x
Tyy
Txx
y
x
y
x
50 100 150
150
100
50
50 100 150
150
100
50
(a)
(b)
Translation
 Scaling and Rotation
 Translation
How to uniformly treat transformations?












=





′
′
y
x
dc
ba
y
x
Observation
















=





′
′
1
10
01
y
x
f
e
y
x
1
( , , ) ( , , 1) ( / , / ) for 0
( , , ) ( / , / ,1) , 0
T T T
T T
P AP
a b c x
P d e f y
g h i
P x y w x w y w x w y w w
x y w x w y w Rα α α
′ =
   
   ′ =    
      
′ ′ ′ ′ ′ ′ ′≡ ⇔ ≡ ≠
′ ′ ′ ′⇔ ∀ ∈ ≠
3. Homogeneous Coordinate System
w
x
y
( , , )T
x y wα ′ ′
1=w
( , ,1)T
x w y w′ ′
(0,0,1)T
( , ) ( , ,1) ( , , )T T T
x y x y wx wy w= ⇔
0≠w
normalized(standard)
No unique homogeneous representation of a Cartesian point !!!
What if ? ( , ,0)T
x y0=w
lim lim( , ,1)
lim( , ,1 )
( , ,0)
T
t
t t
T
t
T
p at bt
a b t
a b
→∞ →∞
→∞
=
=
=
( , ,1)T
tp at bt=
w
• Ideal points !!!
points at infinity
well, ...
( , ,1)T
a b(0,0,1)T
0 0
0 0
1 1 1 0 1
1
t t
a a at
p s t b p t b bt
s t
         
 ÷  ÷  ÷  ÷  ÷
= + ⇒ = + = ÷  ÷  ÷  ÷  ÷
 ÷  ÷  ÷  ÷  ÷
         
+ =
Projective Space
Points in the Euclidean space + Points at infinity
Positions Vectors
Positions and vectors are treated homogeneously!!!
( , , ) , 0T
x y w w ≠ ( , , ) , 0T
x y w w =
0 0
0 0
lim lim( , ,1)
lim( , ,1 )
( , ,0)
T
t
t t
T
t
p at x bt y
a x t b y t t
a b
→∞ →∞
→∞
′ = + +
= + +
=
0 0( , ,1)T
tp at x bt y′ = + +
0 0( , ,1)T
x y
( , ,1)T
tp at bt=
(0,0,1)T
( , ,1)T
a b
lim lim( , ,1) lim( , ,1 ) ( , ,0)T T T
t
t t t
p at bt a b t a b
→∞ →∞ →∞
= = =
In a Euclidean space two lines intersect each other
If they are not parallel
Non-homogeneous treatment !!!∴
However, in a projective space,
two lines do always intersects.
∴ Homogeneous treatment !!!
A
B
No orientation !!!
BA =
∴
However,
Why?
 For detail treatment of this subject, see
 M. Penna and R. Patterson,
Projective Geometry and its Application to Computer Graphics, 1986.
rotation
scaling
translation
perspective transform
P 'P
T '
where
' [ ', ', '] ,
[ , , ] .
T
T
P TP
P x y w
P x y w
=
=
=
2D Transformation Matrices










=
ihg
fed
cba
T
X 'X
 Now, uniform treatment !!!
 Rotation
 Scaling
 Translation



















 −
=










1100
0cossin
0sincos
'
'
'
y
x
w
y
x
θθ
θθ




















=










1100
00
00
'
'
'
y
x
S
S
w
y
x
y
x




















=










1100
10
01
'
'
'
y
x
T
T
w
y
x
y
x
]][]...[[][
][
]][]...[['
12
12
TTTT
PT
PTTTP
n
n
=
=
=
composite transformation matrix
HomeworkHomework
4. Composite Transformations
( , )T
F Fx y
(a) Original position of
object and fixed point
(b) Translate object so that
fixed point (xF, yF) is at origin
(c) Scale object with
respect to origin
(d) Translate object so that
fixed point is returned to position (xF, yF)T
( , )T
F Fx y
][ rT
][ cS 1
][ −
rT
( , )T
R Rx y
(a) Original position of
object and pivot point
(b) Translation of object so that
the pivot point (xR, yR) is at origin
(c) Rotation about origin (d) Translation of object so that
the pivot point is returned to
position (xR, yR)T
( , )T
R Rx y
][ rT
][ tR 1
][ −
rT
x
y
θ
Sy
Sx
[Rt]-1
[Sc][Rt]
Why if Sx = Sy ?
x
y
(0, 0)T
(1, 0)T
(1, 1)T
(0, 1)T
x
y
(0, 0)T
(3/2, 1/2)T
(2, 2)T
(1/2, 3/2)T
45°
Sx = 1
Sy = 2
Final
Position
Final
Position
(a) [Rt][Tr] (b) [Tr][Rt]
Reflection
1
2 3
1’
2’ 3’
Original
position
Reflected
position










−
100
010
001
1
2
3
1’
2’
3’
Original
position
Reflected
position









−
100
010
001
x
x
y y
5. Reflection and Shearing
12
3
1’
2’ 3’
Original
position
Reflected
position










100
001
010
1
2
3
1’
2’
3’
Original
position
Reflected
position










−
−
100
010
001
x
x
y yy = x
45°
[Rt] [Rf
x
]
45°
[Rt]-1
Reflection about y = x










−
−
100
001
010
1 2
3
1’
2’3’
Original
position
Reflected
position
x
yy = -x
(a) (b) (c)
(0, 0) (0, 0) (0, 0)(1, 0)
(1, 1)
(0, 1)
(1, 0)
(3, 1)(2, 1)
(0, 1)
(1, 2)
(1, 3)
x
y
x
y
x
y










100
010
01 xSH










100
01
001
ySH
Shearing
(a) (b)
Raster method for transformation

2d/3D transformations in computer graphics(Computer graphics Tutorials)