2D Transformation
2D Transformation
UNIT-III
2D Geometric Transformations
GEOMETRIC TRANSFORMATION /
COORDINATE TRANSFORMATION
Translations.
2D Scaling
2D Rotation
Matrix Representation of 2D
transformation
Formula for Transformation
Matrix of Transformed object= Matrix of object . Matrix of
transformation
2D TRANSLATIONS.
Point P defined as P( x, y ),
translate to Point P( x, y) a distance d x parallel to x axis, d y parallel to y axis.
x x d x y y d y
Define the column vectors
dx
x
x
P , P ,T
y
y
dy
Now
P P T
P
P
EXAMPLE: 2D TRANSLATION
5
6
6
5
dx = 2
dy = 3
4
3
3
3
2
1
0
where
x
v
,
y
10
x'
v'
,
y
'
X
dx
t
dy
and
x = x + dx
y = y + dy
To move polygons: translate vertices of polygon after adding translation
factors and redraw lines between them.
Translation always Preserves lengths and shape of object (Distortion in
object shape will not occur).
y s y . y
P
0
s y
Now
P S P or
x s x
y 0
0
.
sy
x
y
TYPES OF SCALING
After
Uniform Scaling
If Sx = Sy < 1
If Sx = Sy > 1
If Sx Sy < 1
occurs.
If Sx Sy > 1
Uniform Scaling
EXAMPLE: 2D SCALING
Y
sx 3
sy 2
6
5
4
3
2
2
1
1
0
6
2
3
1
9
2
10
where
x
v
,
y
sx
S
0
s y
x'
v'
y '
x' s x x
y' s y y
HOMOGENEOUS COORDINATES
2D case
3D Case
Add a 4th coordinate to every 3D point
A point (a, b, c) in 3D can be represented as (a,b,c,1) in
homogeneous coordinate system.
Any point (x, y, z, w) in 3D where w!=0 represents a point at
location (x/w, y/w, z/w) in this coordinate system.
HOMOGENEOUS COORDINATES
x' x t x
y' y t y
1 0 0
Translation 0 1 0
tx ty 1
TRANSLATION
Example
of translation
Homogeneous Coordinates
x' 1 0 t x x x t x
y ' 0 1 t y y t
y
y
1 0 0 1 1 1
tx = 2
ty = 1
QUESTION
Object coordinates are (00,10,11,01)
Perform uniform expansion of this object.
13
QUESTION
Q1. Write a 2X2 transformation matrix for
each of the following scaling transformation.
(1)The entire picture is 3 times as large.
(2)The entire picture is 1/3 as large.
(3)The X direction is 4 times as large and the y
direction unchanged.
(4) The x direction reduced to the original
and y direction increased by 7/5 times.
14
QUESTION
Translate the square ABCD whose coorditates
are A(0,0), B(3,0),c(3,3),D(0,3).
Translate this square 1.5 unit in x direction and
0.5 unit in y direction.
After translation performing scaling with scaling
factor sx=1.5 and sy=0.5
15
QUESTION
16
QUESTION
Prove that two scaling transformation is
commutative
Commutative property is
S1.s2=s2.s1
Prove that two successive translation are additive.
17
COMPOSITE TRANSFORMATIONS
T T(t x1 , t y1 ) T(t x 2 , t y 2 )
T(t x1 t x 2 , t y1 t y 2 )
1 0 tx2
0 1 t y2
0 0 1
1 0 t x1 1 0 t x1 t x 2
0 1 t y1 0 1 t y1 t y 2
0 0 1 0 0
COMPOSITE TRANSFORMATIONS
T S( s x1 , s y1 ) S( s x 2 , s y 2 )
S( s x1s x 2 , s y1s y 2 )
sx 2
0
0
0
sy2
0
0 s x1
0 0
1 0
s y1 0
0 1
s x1 s x 2
s y1 s y 2
0
0
1
2D Rotation
20
P(x,y)
P(x,y)
r
x
21
P(x,y)
P(x,y)
x r. cos
y r. sin
r
x
x
22
P(x,y)
P(x,y)
x r. cos
y r. sin
r
x
x
23
Gives us :
x x. cos y. sin
y x. sin y. cos
Rotation (Anticlockwise)
x cos
y sin
sin
.
cos
x
y
Rotation (Clockwise)
x cos
y sin
sin
.
cos
y 24
QUESTION
Rotate a point (10,0) in anticlockwise direction
Angle is 90 degree.
Rotation Anticlockwise
(Anticlockwise)
After rotating this point rotate this point in
x x cos sin
clockwise direction.
y sin
cos
Rotation (Clockwise)
x x
y y
cos
sin
sin
cos
25
TRANSFORMATIONS.
Translation.
P=T
+P
P=S
Scale
Rotation
P=R
P
We would like all transformations to be
multiplications
26
EXAMPLES
1
0
0
1
0
7
1
9 3
1
1
8
12
1
cos( / 2)
sin( / 2)
5
0
0
10
0
sin( / 2)
cos( / 2)
0
0
1
2
3
1
0
2
0 2
1
1
10
30
1
0
1
0
1
0
0
0
2
0 2
1
1
2
2
1
27
Shearing Transformation
The searing transformation when applied to the object it results
distortion of shape. In sharing the parallel layers of any objects are
simply slided with respect to each other.
Types of Shearing Transformation
X- shear: In X-shear y coordinate remain unchanged, but x is
changed.
Y- shear: In Y-shear x coordinate remain unchanged, but y is
changed
x '
y '
x 1 0
y shx 1
X- Shear
x ' x 1 Shy
y ' y 0 1
Y- Shear
28
Question
Q1. Prove that simultaneous shearing in both direction ( X & y
direction) is not equal to the composition of pure shearing along Xaxis followed by pure shear along y- axis.
x '
y '
x
y
x '
y '
1 a
b 1
1 a
0 1
Pure Shearing
1
b
1 a .b a
0
1
b
1
29
QUESTIONS ON 2D
TRANSFORMATION
30
BASIC 2D TRANSFORMATIONS
x' 1 0 t x x
y ' 0 1 t y
y
1 0 0 1 1
Translate
x' cos
y ' sin
1 0
sin
cos
0
Rotate
0
0
0
sy
x
y
1 1
Scale
0
0
1
x
y
1
x ' 1
y ' sh
x
1 0
shy
1
0
Shear
0 x
0 y
1 1
MATRIX COMPOSITION
w' 0 0 1 0
0
1 0 0 1
p =
T(tx,ty)
R()
S(sx,sy)
x
y
w
p
PIVOT-POINT ROTATION
0 1 y sin
0 0 1 0
sin
cos
0
1 0
0 1
0 0
y
1
Translate
34
FIXED-POINT SCALING
T ( x, y ) S ( sx , s y )
T ( x, y )
0 0 sx
1
0
1 0 0
x y 1 0
0 0
1 0 0
sy
0 0 1 0
0 1 x y 1
QUESTION
36
COMPOSITE TRANSFORMATIONS
T R ( 2 ) R (1 )
R ( 2 1 )
cos 2
sin 2
0
sin 2
cos 2
0
0 cos 1
0 sin 1
1 0
sin 1 0
cos 1
0
0
1
cos( 2 1 ) sin( 2 1 ) 0
sin( 2 1 ) cos( 2 1 ) 0
0
0
1
Thanks
38