Ans. to Tut 2
Qn 1 a)
b)
c)
glTranslatef (0.0, 60.0, 0.0); glRotatef (30.0, 0.0, 0.0, 1.0); glScalef (1.5, 1.0, 1.0); object ( );
No, because matrix multiplications is non-commutative.
Another way to visualize the fact is by thought experiment: After
T(0,60,0)RZ (30o )
The origin (0, 0, 0) will be moved to (0, 60, 0). The origin is rotated about itself
then translated. After
R z (30o )T(0,60,0)
(0, 0, 0) will be moved to (-30, 51.96152423, 0). (0, 0, 0) is translated to
(0, 60, 0), then orbital rotate about the origin by 30o .
1 0 0 0cos30o −sin30o 0 01.5 0 0 0 1.5cos30o −sin30o 0 0
0 1 0 60sin30o 0 0 1 0 0
cos30o 0 00 1 0 0 1.5sin30o
cos30o 0 60 0 1 0
0 1 00 0 1 0= 0
0 0 10 0 0 1 0
0 0 0 1 0
0 0 1
Qn 2 a)
Using rule 1, we use coordinate system 1 as the coordinate system. Every physical action is measured in this coordinate system.
1 0 −4 M2←1 =T(4,2)−1= T(−4,−2)= 0 1 −2 0 0 1
1
Check: (0,0)(1) = (−4, −2)(2)
Using rule 2, we use coordinate system 2 as the coordinate system
1 0 −4 𝑴𝑴 =T(−4,−2)= 0 1 −2
2←1 0 0 1
b)
Using rule 1, we use coordinate system 2 as the coordinate system
M3←2 =[T(2,3)S(0.5,0.5)]−1 =S(2,2)T(−2,−3)
2 0 01 0 −2 2 0 −4
=0 2 00 1 −3=0 2 −6
0 0 10 0 1 0 0 1
Useful identity: (𝐴𝐴𝐴𝐴)−1 = 𝐴𝐴−1𝐴𝐴−1
Using rule 2, we use coordinate system 3 as the coordinate system
𝐌𝐌 = 𝐓𝐓(−4, −6)𝐒𝐒(2,2)
1 0 −4 2 0 0 2 0 −4 =�0 1 −6��0 2 0�=�0 2 −6�
3←2
001001001
Check: (0,0)(2) = (−4, −6)(3) (2,0)(2) = (0, −6)(3) c)
It is awkward to find (0,0)(3) expressed in coordinate system 4. Hence it is more convenient to use rule 1. The position of (0,0)(4) is approximately (6.3, 2)(3)
M4←3 =[T(6.3,2)R(45o)]−1 =R(−45o)T(−6.3,−2)
1/ 2 1/ 2 01 0 −6.3 1/ 2 1/ 2 −8.3/ 2
=−1/ 2 1/ 2 00 1 −2=−1/ 2 1/ 2 4.3/ 2
0 0 10 0 1 0 0 1
d) M4←1 =M4←3M3←2M2←1 =R(−45o)T(−6.3,−2)S(2,2)T(−2,−3)T(−4,−2) = R(−45o )T(−6.3,−2)S(2,2)T(−6,−5)
2
M
1←4
=M −1 =T(6,5)S(0.5,0.5)T(6.3,2)R(45o) 4←1
0.5 0 61/ 2 −1/ 2 6.3 0.5/ 2 −0.5/ 2 9.15
=0 0.5 51/ 2 1/ 2 2=0.5/ 2 0.5/ 2 6
0010 0 10 0 1
−1 [ABCZ]
Plane Xp
(5, 10, 5)
Control Tower
X
X,Y,Z, Xp , Yp , Zp areunitvectors.
Zp is in the direction of (cos45o ,sin45o ,tan30o ). Normalizing,
Zp = 23(cos45o,sin45o,tan30o)
3
Qn 3
Useful Identity:
= Z
−1
−1 −1 −1 C B A
(Xp is pointing into the paper)
Z
Yp
Zp
Y
55 X Y Z 10Z×Z Z×X Z 10
M =M −1=p p p = p p p p CT←P P←CT 5 5
00010001 i j k 3sin45o 3cos45o
Z×Zp= 0 0 0 o 1 o=(− 2 , 2 ,0) 3cos45 3sin45 3tan30
222 Xp = Z×Zp =(−sin45o,cos45o,0)
3ijk
Yp = Z p × X p = 2 cos 45o sin 450 tan 30o = (−0.35355339,−0.35355339,0.866025403)
Hence
− sin 45o cos 45o 0 3
−sin450 MCT←P = cos45o
−0.35355339
2 cos45o 5 23sin45o 10 23 tan 30o 5
−0.35355339
CT : Control Tower P : Plane
M =M −1 CT←P P←CT
But M
0 Alternative Method
0.866025403 0001
o o−1 = [T(5,10,5)R (135 )R (60 )]
P←CT z x
Using coordinate system CT, the plane (as an object) is first aligned with the CT coordinate system. (Note that when correctly aligned, the under tray of the plane is facing you.) We wish to find the transformation (an action) that transforms it to the current plane configuration. The transformation needed is
4
[T(5,10,5)R z (135o )R x (60o )]
R x (60o ) will rotate the plane about the X axis such that after rotating, the plane is at
an inclination of 30o, with no banking, facing south. Note that the X axis is that of the coordinate system of CT. (The coordinate system is fixed. It will not be changed after performing an action.)
Now we need to rotate the plane, keeping its inclination, such that it is facing north
east. This is achieved by rotating about the Z axis by 135o, i.e., R z (135o ) . Note that
the Z axis is that of the coordinate system of CT. (The coordinate system is fixed. It will not be changed after performing an action.)
Now the plane is at the origin, inclines 30o, and facing north east. Now we wish to translate it such that it is positioned at (5, 10, 5). This is achieved by T(5,10,5) .
Therefore
M =M −1 =[[T(5,10,5)R (135o)R (60o)]−1]−1 =T(5,10,5)R (135o)R (60o)
CT←P P←CT z x z x
Notes
If you were asked to position the plane as described using OpenGL, here’s the program:
glTranslatef (5, 10, 5); glRotatef (135, 0, 0, 1); glRotatef (60, 1, 0, 0); plane ( );
5