CS计算机代考程序代写 Answers to EE5808 Assignment 2

Answers to EE5808 Assignment 2
Qn 1
a) Parallel projection: all the projection rays are parallel
Perspective projection: all the projection rays pass through the projection reference point (or point of projection)
b) 𝛼 is the angle the projection rays make with the view plane/projection plane Cavalier projection: 𝛼 = 𝑡𝑎𝑛−11
Cabinet projection: 𝛼 = 𝑡𝑎𝑛−12
c) 𝑍 = 2.
The equation is expressed in camera coordinates (or viewer coordinates)
d) gluLookAt (100, 100, 100, 0, 100, 0, 0, 0, 1);
Qn 2
100 0 𝑐𝑜𝑠30𝑜 −𝑠𝑖𝑛30𝑜 00
a) 𝑀2←3 = 𝑇(0, 10, 0)𝑅𝑧(30𝑜) = (0 1 0 10) (𝑠𝑖𝑛30𝑜 𝑐𝑜𝑠30𝑜 0 0) 00100010
00010001 √3/2 −0.5 0 0
b) 𝑀1←2 = 𝑇(−2,10,0)𝑅𝑧(30𝑜)𝑆(0.5,0.5,1.0)
c)
0.5𝑐𝑜𝑠30𝑜 −0.5𝑠𝑖𝑛30𝑜 0 −2 = (0.5𝑠𝑖𝑛30𝑜 0.5𝑐𝑜𝑠30𝑜 0 10)
0010
0001 √3/4 −0.25 0 −2
0.5 √3/2 0 10 0010
=
(0001)
0.25 √3/4 0 10 0010
=
(0001)
1

glTranslatef (10, 0, 0);
Part ( );
glTranslatef (-2, 10, 0); glRotatef (30, 0, 0, 1); glScalef (0.5, 0.5, 1.0);
Part ( ); glTranslatef(0,10,0);
glRotatef (30, 0, 0, 1);
glRotatef (45, 0, 1, 0); Part ( );
// Part 1 // 𝑀1←2
// Part 2 // 𝑀2←3
// Part 3
d) refer to the underlined added code
Qn 3
a)
𝑉𝑅𝑃 = (0,100, −100) 𝑉𝑃𝑁 = (0,100, −100) 𝑉𝑈𝑃 = (0,1,0);
𝑍𝑉𝐶 =(0, 1 ,− 1) √2 √2
𝑖𝑗𝑘 𝑉𝑈𝑃 × 𝑉𝑃𝑁 = |0 1 0
√2 √2
| = (−100,0,0) 0 100 −100
𝑋𝑉𝐶 = (−1,0,0)
𝑖𝑗𝑘11 𝑌 =𝑍 ×𝑋 =| |=(0, , )
𝑉𝐶 𝑉𝐶 𝑉𝐶 0 1/√2 −1/√2 −1 0 0
2

𝑋𝑉𝐶 −𝑉𝑅𝑃 ∙ 𝑋𝑉𝐶 𝑌 −𝑉𝑅𝑃 ∙ 𝑌
−1 0 0 0
𝑀𝑉𝐶←𝑊𝐶 = ( 𝑉𝐶 00010001
𝑉𝐶 ) = (
𝑍𝑉𝐶 −𝑉𝑅𝑃 ∙ 𝑍𝑉𝐶 0 1/√2 −1/√2
) −200/√2
0 1/√2 1/√2
0
b)
1=
(𝑉 ,𝑉 )=(1,1) 𝑝𝑥 𝑝𝑦
𝑉 =√2 𝑝𝑧
𝑍𝑣𝑝 = −5
𝑉 𝑉 𝑀𝑝𝑎𝑟𝑎𝑙𝑙𝑒𝑙= 0 1 −𝑝𝑦 𝑧 𝑝𝑦 =
𝑉 𝑝𝑧
√𝑉 2+𝑉 2 𝑝𝑥 𝑝𝑦
𝑉𝑉 1 0 − 𝑝𝑥 𝑧 𝑝𝑥
𝑉 𝑣𝑝𝑉 𝑝𝑧 𝑝𝑧
1 0 −1/√2 −5/√2
0 1 −1/√2 −5/√2
𝑉𝑣𝑝𝑉 001 0 𝑝𝑧 𝑝𝑧
0 0 1 0 (0 0 0 1 ) (000 1)
c)
i)
Use method 2, P1 is the coordinate system. The transformation is
√3/2 0 0.5 60
𝑇(60,0, −100)𝑅𝑦(30𝑜) = (
0 1 0 0 −0.5 0 √3/2 −100
0001
(2 marks)
)
ii)
(3 marks)
3

void draw_part2 (void)
{
glPushMatrix ( );
glTranslatef (60, 0, -100); glRotatef (30, 0, 1, 0);
glRotatef (15, 1, 0, 0); Part_2 ( );
glPopMatrix ( );
}
void object (void)
{
glTranslatef (10, 10, 10); Part_1 ( );
draw_part2 ( );
glScalef (-1, 1, 1); draw_part2 ( );
}
iii)
The underlined code
4