1
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
a) 𝑀2←3 = 𝑇(0, 10, 0)𝑅𝑧(30
𝑜) = (
1 0 0 0
0 1 0 10
0 0 1 0
0 0 0 1
)(
𝑐𝑜𝑠30𝑜 −𝑠𝑖𝑛30𝑜 0 0
𝑠𝑖𝑛30𝑜 𝑐𝑜𝑠30𝑜 0 0
0 0 1 0
0 0 0 1
)
=
(
√3/2 −0.5 0 0
0.5 √3/2 0 10
0 0 1 0
0 0 0 1 )
b) 𝑀1←2 = 𝑇(−2, 10, 0)𝑅𝑧(30
𝑜)𝑆(0.5, 0.5, 1.0)
= (
0.5𝑐𝑜𝑠30𝑜 −0.5𝑠𝑖𝑛30𝑜 0 −2
0.5𝑠𝑖𝑛30𝑜 0.5𝑐𝑜𝑠30𝑜 0 10
0 0 1 0
0 0 0 1
)
=
(
√3/4 −0.25 0 −2
0.25 √3/4 0 10
0 0 1 0
0 0 0 1 )
c)
2
glTranslatef (10, 0, 0);
Part ( ); // Part 1
glTranslatef (-2, 10, 0); // 𝑀1←2
glRotatef (30, 0, 0, 1);
glScalef (0.5, 0.5, 1.0);
Part ( ); // Part 2
glTranslatef(0,10,0);
glRotatef (30, 0, 0, 1); // 𝑀2←3
glRotatef (45, 0, 1, 0);
Part ( ); // Part 3
d) refer to the underlined added code
Qn 3
a)
𝑉𝑅𝑃 = (0,100, −100)
𝑉𝑃𝑁 = (0,100,−100)
𝑉𝑈𝑃 = (0,1,0);
𝑍𝑉𝐶 = (0,
1
√2
,−
1
√2
)
𝑉𝑈𝑃 × 𝑉𝑃𝑁 = |
𝑖 𝑗 𝑘
0 1 0
0 100 −100
| = (−100,0,0) 𝑋𝑉𝐶 = (−1,0,0)
𝑌𝑉𝐶 = 𝑍𝑉𝐶 × 𝑋𝑉𝐶 = |
𝑖 𝑗 𝑘
0 1/√2 −1/√2
−1 0 0
| = (0,
1
√2
,
1
√2
)
3
𝑀𝑉𝐶←𝑊𝐶 = (
𝑋𝑉𝐶 −𝑉𝑅𝑃 ∙ 𝑋𝑉𝐶
𝑌𝑉𝐶 −𝑉𝑅𝑃 ∙ 𝑌𝑉𝐶
𝑍𝑉𝐶 −𝑉𝑅𝑃 ∙ 𝑍𝑉𝐶
0 0 0 1
) = (
−1 0 0 0
0 1/√2 1/√2 0
0 1/√2 −1/√2 −200/√2
0 0 0 1
)
b)
1 =
𝑉𝑝𝑧
√𝑉𝑝𝑥
2
+ 𝑉𝑝𝑦
2
(𝑉𝑝𝑥, 𝑉𝑝𝑦) = (1,1)
𝑉𝑝𝑧 = √2
𝑍𝑣𝑝 = −5
𝑀𝑝𝑎𝑟𝑎𝑙𝑙𝑒𝑙 =
(
1 0 −
𝑉𝑝𝑥
𝑉𝑝𝑧
𝑧𝑣𝑝
𝑉𝑝𝑥
𝑉𝑝𝑧
0 1 −
𝑉𝑝𝑦
𝑉𝑝𝑧
𝑧𝑣𝑝
𝑉𝑝𝑦
𝑉𝑝𝑧
0 0 1 0
0 0 0 1 )
=
(
1 0 −1/√2 −5/√2
0 1 −1/√2 −5/√2
0 0 1 0
0 0 0 1 )
c)
i)
Use method 2, P1 is the coordinate system.
The transformation is
𝑇(60,0, −100)𝑅𝑦(30
𝑜) = (
√3/2 0 0.5 60
0 1 0 0
−0.5 0 √3/2 −100
0 0 0 1
)
(3 marks) (2 marks)
ii)
4
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