Tut 1
Qn 1
The three dimensional coordinates of the house-shaped object below are as follows:
a = (0, 0, 0)
d = (10, 10, -20) g = (0, 10, 0)
b = (10, 0, 0)
e = (5, 15, -20) h = (0, 10, -20)
c = (10, 0, -20)
f = (5, 15, 0)
i = (0, 0, -20) j = (10, 10, 0)
right
e f
h
d
g
j
i
a
front
The front face is denoted by F1 , the right face F2 , the left face F3 , the back face F4 , the right roof F5 , the left roof F6 , and the ground face F7 .
a) Construct the vertex, edge, face, and attribute table of a polygonal model of the object.
b) Determine the outward unit surface normal of the left roof face.
c) Derive the equation of the face d e f j in the form
Ax+By+Cz+D=0
such that if the (LHS > 0) ⇔ (Outside) and vice versa.
d) Suggest a method for determining whether a point is inside or outside the house.
e) Suggest a general method for determining whether a point is inside or outside any volumetric object.
f) Suggest an application for the function in e).
left
c b
Qn 2
h
d
e a
a(0, 0,0) e(0,0,5) b (10, 0, 0) f (10, 0, 5) c(10,4,0) g (10, 4, 5) d ( 0, 25, 0) h ( 0, 25, 5)
g f
c b
Two popular object representation methods are tables and quadrilateral mesh.
a) Using tables, write C code to represent the face bcgf in the form of vertex table, edge table and face table. Use vertices to form the face table.
b) Represent the object above, except the top and bottom face, as a quadrilateral mesh. To save time, you are only required to draw a 2D array and put the alphabet (e.g. a) to each of the vertex of the array to show your idea.
c) Derive the plane equation of cdhg.
d) Give an advantage of using the mesh representation compared to using the table
representation.
Qn 3
a) In CG, the parametric form is used instead of the non-parametric form. What is the reason(s)?
b) The non-parametric form of a superellipsoid is given by
x 2s2 y 2s2 s2 s1 z 2s1
r +r +r =1 x y z
2
Derive its equivalent parametric form. Give the physical meaning of any additional variables you introduce.
Qn 4
Consider the following program fragment:
void calculate_mesh (void)
{
for (int i=0; i