Professional Documents
Culture Documents
2 D Transformation
2 D Transformation
hnew
hold
Scale in x, by 2, say :
2 (x 0 x1), y0 y1 ( 2 x0 , y0 ) ( 2 x1 , y1)
x x
(2 x0 , y0 )
( x0 , y0 ) (2 x0 , y0 )
y
2( x0 x1), y0 y1
y
2( x0 x1), y0 y1
( x0 x1), y0 y1 ( x0 x1), y0 y1
( x1 , y1 )
P( x, y )
P ( x, y ) r y P ( x, y )
(0,0) x
(0,0)
x2 = sxx1 y2 = syy1
204481 Foundation of Computer Graphics By Eko
15 Syamsudin & Anisya November 16, 2021
Transformations: Scaling (3/5)
Simple scaling -
relative to (0,0) P1( x, y )
General form:
P1( x, y )
x s x * x
y s y * y
P1(2,3) P1(4,3)
Ex: sx = 2 and sy=1
P 2(3,1) P 2(6,1)
Rotation:
x’ = xcos - ysin
cos sin x x cos y sin
sin
y’ = xsin + ycos cos y x sin y cos
Translation: t x x x t x
x’ = x + tx t y t
y’ = y + ty
y y y
(a,1)
(0,1) (1,1)
(1, 0) (1, 0)
204481 Foundation of Computer Graphics By Eko
20 Syamsudin & Anisya November 16, 2021
Transformations: Shear (2/2)
1 0 x x
Shear in y: Shy
b 1 y
bx y
(0,0) (0,0)
(1, 0)
(0,0) (0,0)
(1,0) (1,0)
(a,1 ab)
(1,1 b) (1 a ab,1 b)
(0,1) (0,1)
(1, b)
(1 ab, b)
(0,0) (0,0)
204481 Foundation of Computer Graphics By Eko
22 Syamsudin & Anisya November 16, 2021
Shear in y then in x
(1,1) (0,1) (a,1) (1 a,1)
(0,1)
(a,1 ab)
(1,1 b)
(0,1)
(0,1)
(1, b) (1, b)
(0,0)
204481 Foundation of Computer Graphics By Eko
23 Syamsudin & Anisya November 16, 2021
Homogeneous coordinate
As translations do not have a 2 x 2 matrix
representation, we introduce homogeneous
coordinates to allow a 3 x 3 matrix representation.
The Homogeneous coordinate corresponding to the
point (x,y) is the triple (xh, yh, w) where:
xh = wx
yh = wy
For the two dimensional transformations we can set
w = 1.
204481 Foundation of Computer Graphics By Eko
24 Syamsudin & Anisya November 16, 2021
Matrix representation
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 s y 0 Tx , y 0 1 t y
0 0 1 0 0 1
cos t sin t 0
P ( x , y ,1) ( x , y ,1) sin t cos t 0 PS (t )
0 0 1