Professional Documents
Culture Documents
2D Transformations
2D Transformations
2-D Transformations
Contents
1. Homogeneous coordinates
2. Matrices
3. Transformations
4. Geometric Transformations
5. Inverse Transformations
6. Coordinate Transformations
7. Composite transformations
a b c x a* x b* y c* z
d e f y d * x e * y f * z
g h i 3 x 3 z 3 x1 g * x h * y i * z 3 x1
2 V = txI+tyJ
1
0
1 2 3 4 5 6 7 8 9 10
x
Note: House shifts position relative to origin
April 17, 2019 Computer Graphics 20
Geometric Translation Example
Translation by 3I+2J
y
6
(5, 5)
5
4
(2, 3)
3 (6, 3)
(4, 3)
2
1
(1, 1) (3, 1)
1 0 tx x x
Tv 0 1 ty P y P y
0 0 1 1 1
3 6 9
3 3
2
1 2 3
1 1
0
1 2 3 4 5 6 7 8 9 10
x
Note: House shifts position relative to origin
April 17, 2019 Computer Graphics 25
Geometric Scaling
– The scaling of a point P(x,y) by scaling factors Sx and Sy
about origin can be written in matrix form as:
P Ssx, sy( P) where
sx 0 0 x x
Ssx, sy 0 sy 0 P y P y
0 0 1 1 1
x sx 0 0 x sx x
such that y 0 sy 0 y sy y
1 0 0 1 1 1
6
(4,6)
4
(2, 3)
3
2
(2, 2) (6, 2)
1
(1, 1) (3, 1)
0 2019
April 17,
1 2 3
Computer Graphics
4 5 6 7 8 9 10
27
Geometric Transformations
–Translation
–Scaling
–Rotation
–Reflection
–Shearing
Geometric Rotation
– The rotation of a point P (x,y) about origin, by specified
angle θ (>0 counter clockwise) can be obtained as
x’ = x × cosθ – y × sinθ
Let us derive these equations
y’ = x × sinθ + y × cosθ
– To rotate an object we have to rotate all coordinates
y
y 6
4
(x',y')
• 3
2
• (x,y) 1
6
x 0
1 2 3 4 5 6 7 8 9 10
x
April 17, 2019 Computer Graphics 29
Geometric Rotation
– The rotation of a point P(x,y) by an angle about origin
can be written in matrix form as:
P R ( P) where
cos sin 0 x x
R sin cos 0 P y P y
0 0 1 1 1
x cos sin 0 x cos x sin y
such that y sin cos 0 y sin x cos y
1 0 0 1 1 1
(2,1)
2
(0,0) (2,0)
0 2019 1
April 17, 2 3 4Computer
5 Graphics
6 7 8 9 10 31
Geometric Transformations
–Translation
–Scaling
–Rotation
–Reflection
–Shearing
Geometric Reflection
– Mirror reflection is obtained about X-axis
x’ = x
y’ = – y
– Mirror reflection is obtained about Y-axis
x’ = – x
y
y’ = y 6
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1
0
1 2 3 4 5 6 7 8 9 10
x
2 2
1 (1,1) 1 ( 2,1)
0
1 2 3 4 5
x 0
1 2 3 4 5
x
y y
3 3 a=2
2 2
( 2,1)
1 (1,1) 1 ( 3,1)
0
1 2 3 4 5
x 0
1 2 3 4 5
x
y
3 3 b=3
( 1,3)
2 2
1 (1,1) 1
0
1 2 3 4 5
x 0
1 2 3 4 5
x
1 0 tx
1
Tv Tv 0 1 ty
0 0 1
– Inverse Scaling: Division by Sx and Sy
1 Sx 0 0
S sx,sy S1/ sx,1/ sy 0 1 Sy 0
1
0 0 1
April 17, 2019 Computer Graphics 45
Inverse Transformations
– Inverse Rotation: Rotation by an angle of –
cos sin 0
R R sin 0
1
cos
0 0 1
1 0 0
M x M x 0 1 0
1
0 0 1
April 17, 2019 Computer Graphics 46
Contents
1. Homogeneous coordinates
2. Matrices multiplications
3. Transformations
4. Geometric Transformations
5. Inverse Transformations
6. Coordinate Transformations
7. Composite transformations
It first applies C to v, then applies B to the result, then applies A to the result of that.
RT ( h, k ) H T ( h, k ) RT ( h, k ) H
3
April 17, 2019 Computer Graphics 4 54
Composite Transformations
Let P is the object point whose rotation by an angle about the fixed point (h,k)
is to be found. Then the composite transformation R,(h,k) can be obtained by
performing following sequence of transformations :
1. Translate (h,k) to origin and the new object point is found as
P1 = TV(P) where V= – hI – kJ
2. Rotate object about origin by angle and the new object point is
P2 = R(P1)
3. Retranslate (h,k) back the final object point is
PF = T-1V(P2) = T-V (P2)
The composite transformation can be obtained by back substituting
PF = T-1V(P2)
= T-V R(P1)
= T-V RTV(P) where V = – hI – kJ
(2, 3)
3
(1, 2) (3, 2)
2
1
(2, 1)
0 1 2 3 4 5 6 7 8 9 10 x
April 17, 2019 Computer Graphics 60
Exercises 2
Scale
y the shape below by 3 in x and 2 in y
(2, 3)
3
(1, 2) (3, 2)
2
1
(2, 1)
0 1 2 3 4 5 6 7 8 9 10 x
April 17, 2019 Computer Graphics 61
Exercises 3
Rotate the shape below by 30° about the origin
y
(2, 3)
3
(1, 2) (3, 2)
2
1
(2, 1)
0 1 2 3 4 5 6 7 8 9 10 x
April 17, 2019 Computer Graphics 62
Exercise 4
Write out the homogeneous matrices for the previous
three transformations
Translation Scaling Rotation
__ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __
(4, 3) (6, 3)
3
2
(5, 2)
1
0 1 2 3 4 5 6 7 8 9 10 x
April 17, 2019 Computer Graphics 64
Exercise 6
Rotate a triangle ABC A(0,0), B(1,1), C(5,2) by 450
1. About origin (0,0)
2 2 2 2 0
2. About P(-1,-1)
R 450 2 2 2 2 0
0 0 1
0 1 5 2 2 2 2 1
[ABC ] 0 1 2
R 45 , ( 1, 1) 2 2
0
2 2
2 1
1 1 1 0
0 1
0 1 5
[ABC ] 0 1 2
1 1 1
2 0 5 5 3 5
S 2, 2, (5, 2) 0 2 2 [ ABC ] 2 0 2
0 0 1 1 1 1
PF = T-V(PIV)
= T-V.R (PIII)
= T-V.R . Mx(PII)
= T-V.R . Mx . R-(PI)
= T-V.R . Mx . R-. TV(P)
0 0 1
April 17, 2019 Computer Graphics 70
Exercise 8
cos 2 sin 2 2 sin cos 2b sin cos
M L 2 sin cos sin 2 cos 2 b(cos 2 sin 2 ) b
0 0 1
cos 2 sin 2 b sin 2
sin 2 cos 2 b cos 2 b
0 0 1
1 tan 2 tan 2
putting cos 2 , sin 2 , and tan m ( why ?)
1 tan
2
1 tan
2
1 m 2 2m 2bm
2
1 m 2
1 m 2
1 m
2 m m 2
1 2b
C.T .M .
1 m 1 m 1 m
2 2 2
0 0 1
April 17, 2019 Computer Graphics 71
Exercise 9
Reflect the diamond shaped polygon whose vertices are A(-1,0)
B(0,-2) C(1,0) and D(0,2) about
1. Horizontal Line y=2 0 1 2
2.Vertical Line x = 2 My x 2 1 0 2
3. Line L: y=x+2.
0 0 1
1 0 0 1 0 4
My 2 0 1 4 Mx 2 0 1 0
0 0 1 0 0 1
0 1 0
My x 1 0 0
0 0 1
April 17, 2019 Computer Graphics 73
Exercise 11
Prove that
a. Two successive translations are additive /commutative.
b. Two successive rotations are additive /commutative.
c. Two successive Scaling are multiplicative /commutative.
d. Two successive reflections are nullified /Invertible.
0 1 2 3 4 5 6 7 8 9 10
April 17, 2019 Computer Graphics x
83
April 17, 2019 Computer Graphics 84