Lesson 4 - 2D Transformation
Lesson 4 - 2D Transformation
Lesson 4 - 2D Transformation
Lesson 4:
2D Transformations
Transformation
Translation
Scaling
Rotation
Homogenous coordinates
Reflection
Shearing
Transformations
3
x
Translation
4
Consider a triangle with vertices A(0, 0), B(2, 2) and C(3, 1),
translate 2 units in the Horizontal direction and 1 unit in the
Vertical direction.
(2,2)
(3,1)
(0,0)
Scaling
7
(2,2)
(1,1)
(2,2)
(3,1)
(0,0)
Scaling (With Respect to a Fixed Point)
10
Step Three: Translate the origin back on the fixed point (Xf, Yf):
X3 = X2 + Xf
Y3 = Y2 + Yf
Uniform and Non-Uniform Scaling
11
y y
q q
o x o x
y
Rotate point (x, y) about the (x’, y’)
o x
y
(x’, y’)
x = r cos (f) y = r sin (f)
x’ = r cos (f q) y’ = r sin (f q) (x, y)
q
r
f
o x
Rotation (2)
14
q (x,y)
x’ = r cos (f q) r
f
= r cos(f) cos(q) – r sin(f) sin(q)
= x cos(q) – y sin(q)
x’ = x cos(q) – y sin(q)
y’ = r sin (f q) y’ = y cos(q) + x sin(q)
= r sin(f) cos(q) + r cos(f) sin(q)
= y cos(q) + x sin(q)
Examples: Rotation
15
(x,y) (x,y)
Homogeneous Co-ordinates
17
x x cosq sinq 0
Rotation about origin by q: y y . sinq cosq 0
1
1 0 0 1
x' Sx 0 0 x
Scaling with (Sx, Sy): y ' 0 Sy 0. y
1 0 0 1 1
Inverse Transformations
19
Inverse Scaling: x’ = x / Sx
S-1 (Sx, Sy) = S (1/Sx, 1/Sy)
y’ = y / Sy
x’ = x cos(q) + y sin(q)
Inverse Rotation: R-1(q) = R (– q)
y’ = y cos(q) – x sin(q)
Reflection (1)
20
2 3 2 2’
x 1 1’
2’ 3’
3 3’
Reflected
Position
x
1’
Reflection (2)
21
Reflected 3’
Position 3’ 2’
x
Reflection Examples
22
y-axis
x-axis
Origin
Shearing
23