CS计算机代考程序代写 Ans

Ans

1

Ans. to Tut 2

Qn 1

a)









 −

=















 −







1000
0100
60030cos30sin5.1
0030sin30cos5.1

1000
0100
0010
0005.1

1000
0100
0030cos30sin
0030sin30cos

1000
0100
60010
0001

oo

oo

oo

oo

b) glTranslatef (0.0, 60.0, 0.0);

glRotatef (30.0, 0.0, 0.0, 1.0);
glScalef (1.5, 1.0, 1.0);

object ( );

c) No, because matrix multiplications is non-commutative.

Another way to visualize the fact is by thought experiment: After

)30()0,60,0( oZRT

The origin (0, 0, 0) will be moved to (0, 60, 0). The origin is rotated about itself

then translated.

After

)0,60,0()30( TR oz

(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 o30 .

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
12 )2,4(


← = TM = )2,4( −−T =







100
210
401

2

Check: (0,0)(1) = (−4,−2)(2)

Using rule 2, we use coordinate system 2 as the coordinate system

𝑴𝑴2←1 = )2,4( −−T =






100
210
401

b)

Using rule 1, we use coordinate system 2 as the coordinate system

)3,2()2,2()]5.0,5.0()3,2([ 123 −−==

← TSSTM

=






=










100
620
402

100
310
201

100
020
002

Useful identity: (𝐴𝐴𝐴𝐴)−1 = 𝐴𝐴−1𝐴𝐴−1

Using rule 2, we use coordinate system 3 as the coordinate system

𝐌𝐌3←2 = 𝐓𝐓(−4,−6)𝐒𝐒(2,2)

= �
1 0 −4
0 1 −6
0 0 1

��
2 0 0
0 2 0
0 0 1

� = �
2 0 −4
0 2 −6
0 0 1

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)

)2,3.6()45()]45()2,3.6([ 134 −−−==

← TRRTM
oo

=





=











100

2/3.42/12/1
2/3.82/12/1

100
210
3.601

100
02/12/1
02/12/1

d) )2,4()3,2()2,2()2,3.6()45(12233414 −−−−−−−== ←←←← TTSTRMMMM

o

= )5,6()2,2()2,3.6()45( −−−−− TSTR o

3

)45()2,3.6()5.0,5.0()5,6(11441
oRTSTMM == −←←

=




 −





100
22/12/1
3.62/12/1

100
55.00
605.0

=




 −

100
62/5.02/5.0
15.92/5.02/5.0

Useful Identity: [ ] 11111 −−−−− = ABCZZ ABC

Qn 3

X, Y, Z, pX , pY , pZ are unit vectors.

pZ is in the direction of )30tan,45sin,45(cos

ooo . Normalizing,

)30tan,45sin,45(cos
2
3 ooo

p =Z

Zp
Xp

Yp

Plane

X

Z

Y

Control Tower

(5, 10, 5)

(Xp is pointing into the paper)

4








××

=







== −←←

1000
5

10
5

1000
5

10
5

1 ppppppp
CTPPCT

ZXZZZZYX
MM

)0,
2

45cos3
,

2
45sin3

(

2
30tan3

2
45sin3

2
45cos3

100
0

oo

oo
p

kji
−==×ZZ

)0,45cos,45sin( oopp ZZX −=×=

)866025403.0,35355339.0,35355339.0(
045cos45sin
30tan45sin45cos

2
3 0 −−=

=×=
oo

oo
ppp

kji
XZY

Hence















−−

=←

1000

530tan
2
3

866025403.00

1045sin
2
3

35355339.045cos

545cos
2
3

35355339.045sin 0

o

oo

o

PCTM

Alternative Method

CT : Control Tower
P : Plane

1−
←← = CTPPCT MM

But [ ] 1)60()135()5,10,5( −← = oxozCTP RRTM

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

5

[ ])60()135()5,10,5( oxoz RRT

)60( oxR 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., )135( ozR . 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 )5,10,5(T .

Therefore

)60()135()5,10,5(])]60()135()5,10,5([[ 111 ox
o

z
o

x
o

zCTPPCT RRTRRTMM ===
−−−

←←

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 ( );