it- 601: computer graphics lecture-06 two –dimensional transformations
DESCRIPTION
Jesmin Akhter Lecturer,IIT Jahangirnagar University, Savar , Dhaka,Bangladesh. IT- 601: Computer Graphics Lecture-06 Two –Dimensional Transformations. a c. b d. Matrix Math. Why do we use matrix? More convenient organization of data. More efficient processing - PowerPoint PPT PresentationTRANSCRIPT
IT- 601: Computer GraphicsLecture-06
Two –DimensionalTransformations
Jesmin Akhter Lecturer,IIT
Jahangirnagar University, Savar, Dhaka,Bangladesh
04/22/23
Matrix Math• Why do we use matrix?
– More convenient organization of data.– More efficient processing– Enable the combination of various
concatenations
• Matrix addition and subtraction
ab
cd
a cb d=
• Matrix Multiplication– Dot product
Matrix Math
a bc d
e fg h
. = a.e + b.g a.f + b.hc.e + d.g c.f + d.h
• What about this?
• Type of matrix
Matrix Math
1 2 . 1 23 1
= 7 4
23
. 1 23 1 = No!!
a b ab
Row-vector Column-vector
• Is there a difference between possible representations?
Matrix Math
dfce
bfae
f
e
dc
ba
dfbecfae dc
bafe
dfcebfae db
cafe
• The column-vector representation for a point.
DyCx
ByAx
y
x
DC
BA
Matrix Math
• Example– Find the transformed point, P’, caused by
rotating P= (5, 1) about the origin through an angle of 90.
Rotation
cossin
sincos
cossin
sincos
yx
yx
y
x
90cos190sin5
90sin190cos5
0115
1105
5
1
Composite Transformation• We can represent any sequence of transformations
as a single matrix.– Composite transformations – matrix • matrix.
• Composite transformations:– Rotate about an arbitrary point – translate, rotate,
translate– Scale about an arbitrary point – translate, scale,
translate– Change coordinate systems – translate, rotate, scale
• Does the order of operations matter?
Composition Properties
• Is matrix multiplication associative?– (A.B).C = A.(B.C)
dhlcfldgjcejdhkcfkdgicei
bhlaflbgjaejbhkafkbgiaei
lk
ji
dhcfdgce
bhafbgae
lk
ji
hg
fe
dc
ba
dhldgjcflcejdhkdgicfkcei
bhlbgjaflaejbhkbgiafkaei
hlgjhkgi
flejfkei
dc
ba
lk
ji
hg
fe
dc
ba
?
• Is matrix multiplication commutative?– A . B = B . A
Composition Properties
?
dhcfdgce
bhafbgae
hg
fe
dc
ba
hdgbhcga
fdebfcea
dc
ba
hg
fe
Order of operationsSo, it does matter. Let’s look at an example:
1. Translate2. Rotate
1. Rotate
2. Translate
Composite Transformation Matrix• Arrange the transformation matrices in order from right to left.
• General Pivot- Point Rotation• Operation :-
1. Translate (pivot point is moved to origin)2. Rotate about origin
3. Translate (pivot point is returned to original position)
T(pivot) • R() • T(–pivot)
1 0 -tx
0 1 -ty
0 0 1
cos -sin 0sin cos 0 0 0 1
1 0 tx
0 1 ty
0 0 1 . .
cos -sin -tx cos+ ty sin + tx
sin cos -tx sin - ty cos + ty
0 0 1
cos -sin -tx cos+ ty sin sin cos -tx sin - ty cos 0 0 1
1 0 tx
0 1 ty
0 0 1 .
• Example– Perform 60 rotation of a point P(2, 5) about a
pivot point (1,2). Find P’?
Composite Transformation Matrix
cos -sin -tx cos+ ty sin + tx
sin cos -tx sin - ty cos + ty
0 0 1
xy1
.
0.5 -0.866 -1.0.5 + 2.0.866 + 1 0.866 0.5 -1.0.866- 2.0.5 + 20 0 1
251
.
0.5 - 0.866 2.232 0.866 0.5 0.1340 0 1
251
. =-1.0984.366 1
P’ = (-1, 4)
Sin 60 = 0.8660Cos 60 = 1/2
Composite Transformation Matrix
General Fixed-Point Scaling Operation :-
1. Translate (fixed point is moved to origin)2. Scale with respect to origin
3. Translate (fixed point is returned to original position)
T(fixed) T(fixed) • • S(scale) S(scale) • • T(–fixed)T(–fixed)
Find the matrix that represents scaling of an object with respect to any fixed point?
Given P(6, 8) , Sx = 2, Sy = 3 and fixed point (2, 2). Use that matrix to find P’?
Answer1 0 -tx
0 1 -ty
0 0 1
Sx 0 0 0 Sy 0 0 0 1
1 0 tx
0 1 ty
0 0 1 . .
Sx 0 -tx Sx 0 Sy -ty Sy 0 0 1
1 0 tx
0 1 ty
0 0 1 . =
x =6, y = 8, Sx = 2, Sy = 3, tx =2, ty = 2
Sx 0 -tx Sx + tx
0 Sy -ty Sy + ty
0 0 1
2 0 -2( 2) + 20 3 -2(3) + 20 0 1
.681
=10 20 1
Composite Transformation Matrix
General Scaling Direction Operation :-
1. Rotate (scaling direction align with the coordinate axes)2. Scale with respect to origin
3. Rotate (scaling direction is returned to original position)
R(–) • S(scale) • R()
Find the composite transformation matrixby yourself !!
Other transformationsReflection:
x-axis y-axis
100
010
001
100
010
001
Other transformationsReflection:
origin
100
010
001
Other transformationsShear:
x-direction y-direction
100
010
01 xsh
100
01
001
ysh
Another Example.
Scale
Translate
Rotate
Translate