Page 146 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 146
Lab on Computer Graphics
Notes 8.2.8 Combining Transformations
We saw that the essential scaling and rotating transformations are always regarding the origin.
To scale or rotate about an exacting point (the fixed point) we should first translate the object so
that the fixed point is at the origin. We then perform the scaling or rotation and then the opposite
of the original translation to move the set point back to its original position. For example, if we
want to scale the triangle by 2 in each direction about the point fp = (1.5,1), we first translate all
the points of the triangle by T = (–1.5,1), scale by 2 (S) , and then translate back by T = (1.5,1).
Mathematically this looks like.
x È 2 ˘ È 20˘ È Ê x1˘ È - . È 15˘
.
15˘ˆ
q = Í 2 ˙ = Í ˙ Í Á ˙ + Í ˙˜ = Í ˙
˚ Î
Î y Í ˚ ˙ Î 02 Ë y1 ˚ Î - 1 ˚¯ Î Î 1 ˚
Order Matters!
Notice the order in which these transformations are performed. The first (rightmost)
transformation is T and the last (leftmost) is –T. If you apply these transformations in a different
order then you will get very different results. For example, what happens when you first apply
T followed by –T followed by S? Here T and –T cancel each other out and you are simply left
with S. Sometimes (but be careful) order does not matter, For example, if you apply multiple
2D rotations, order makes no difference:
R1 R2 = R2 R1
But this will not necessarily be true in 3D.
8.2.9 Transformation between Translation and Scale
Scale then Translate: p’ = T ( S p ) = TS p
Ê 10 3ˆ Ê 2 00ˆ Ê 2 0 3ˆ
˜
Á
TS = 01 1 ˜ Á 0 2 0 = Á Á 0 21 ˜ ˜
Á
˜ Á
˜
˜ Á
Á Ë 00 1¯ Ë 00 1¯ ˜ Á Ë 00 1¯ ˜
Translate then Scale: p’ = S (T p ) = ST p
Ê 2 00ˆ Ê 1 0 3ˆ Ê 2 0 6ˆ
Á
˜
ST = 0 2 0 ˜ Á 01 1 = Á Á 0 22 ˜ ˜
˜
Á
˜ Á
Á Ë 00 1¯ Ë 00 1¯ ˜ Á Ë 00 1¯ ˜
˜ Á
8.2.10 Concatenation of Scales
The matrix product S (sx 1 ,*sy 1 ) S (sx 2 ,*sy 2 ) is:
s È x1 0 0˘ s È x2 0 0˘ È s ◊ s x2 0 0˘
x1
˙
Í Í 0 s y1 0 ˙ Í 0 s y2 0 = Í Í 0 s ◊ s y2 0 ˙ ˙
˙
˙ Í
y y1
Í Î 0 0 1˙ Í 0 0 1˙ ˚ Í Î 0 0 1˙ ˚
˚ Î
Only diagonal matrix in the elements easy to multiply!
8.2.11 Other Properties of Scaling
• It does not preserve lengths in objects.
• It does not preserve angles between parts of objects (except when scaling is uniform,
x = sy).
• If it is not at origin, translates house relative to origin– often not desired.
8.2.12 Conclusion: 2D Transformations
1. Simple, consistent matrix notation
• using homogeneous coordinates
140 LOVELY PROFESSIONAL UNIVERSITY