CS代考 COSC363-19S1 (C) – cscodehelp代写
Mid-year Examinations, 2019 COSC363-19S1 (C)
No electronic/communication devices are permitted. Students may take exam question paper away after the exam.
Computer Science and Software Engineering EXAMINATION
Mid-year Examinations, 2019
Copyright By cscodehelp代写 加微信 cscodehelp
COSC363-19S1 (C) Computer Graphics
Examination Duration: 180 minutes
Exam Conditions:
Closed Book exam: Students may not bring in any written or printed materials. Calculators with a ‘UC’ sticker approved.
Materials Permitted in the Exam Venue:
Materials to be Supplied to Students:
1 x Standard 16-page UC answer book
Instructions to Students:
Answer all questions.
This is a closed book exam. No written or printed material is allowed.
Check carefully the number of marks allocated to each question. This suggests
the degree of detail required in each answer, and the amount of time you should
spend on the question.
Use the separate answer booklet provided for answering all questions.
No form of collaboration is permitted.
This question paper carries a total of 100 marks with 50% contribution to the final
For Examiner Use Only
Question Mark
Page 1 of 8
Mid-year Examinations, 2019
COSC363-19S1 (C)
Questions Start on Page 3
Important Formulae
If v1 = (x1, y1, z1) and v2 = (x2, y2, z2), then the cross-product of the two vectors is given by v1v2 = (y1z2 y2z1, z1x2 z2x1, x1y2 x2y1).
Rotation matrices:
R()0 cos sin 0
x 0 sin cos 0
0 0 0 1
cos 0 sin 0 R() 0 1 0 0
y sin 0 cos 0 0 0 0 1
cos sin 0 0 R()sin cos 0 0 z 0010
0 0 01
Page 2 of 8
Mid-year Examinations, 2019 COSC363-19S1 (C)
Question 1. [17 marks for the whole question] Transformations
For each of the questions (a)-(c) given below, write a small code segment containing only OpenGL
transformation functions for generating the required output.
(a). (3 Marks) Refer to Fig. 1a. In the figure, ‘A’ refers to the initial display obtained by calling the function glutSolidTeapot(1). Write the code segment required for producing the teapot ‘B’ located at a point on the xy-plane at an angle 30 from the x-axis. The distance of the point ‘B’ from the origin is 3 units (radius of the circular section shown in the figure)
(b). (4 Marks) Refer to Fig. 1b. In the figure, ‘A’ refers to the initial display of an object obtained by calling a user-defined function drawArrow(). Write the code segment required for scaling the object along the x-axis by a factor of 2, and then rotating the scaled object about a pivot point (4, -2, 0) by 30 about the z-axis.
(c) (5 Marks) Refer to Fig. 1c. In the figure, ‘A’ refers to the initial display of an object obtained by calling a user-defined function drawArrow(). The length of the arrow shaped object is 3 units. Create another copy of the object and reflect it along the x-axis (horizontal flip), and move the objects along the x-axis to produce the display denoted by ‘B’. Apply a single rotation by 30 about the z-axis to both objects to get the final output denoted as ‘C’. (hint: Use glPushMatrix() and glPopMatrix())
(d) (4 Marks) A point (x, y, z) is transformed using a set of matrices as follows:
Please describe the sequence of transformations (including the types of transformations, parameters, and the order of transformations) represented by the above matrix expression.
(e) (1 Mark) Based on your answer to the previous question (d), what would be the output if the above transformation was applied to the point (0, 0, 0, 1)? You are not required to perform any numerical computation or matrix multiplication.
Page 3 of 8
Mid-year Examinations, 2019
COSC363-19S1 (C)
Question 2. [10 marks for the whole question] Mathematical Preliminaries n
(3, 0, 1) a
(a). (5 Marks) Compute the vectors a, b, indicated in the figure, and use them to compute the components of the normal vector n of the triangle.
(b). (2 Marks) Normalize the vector n to a unit vector.
(c). (3 Marks) Compute the angle between the normal vector n and the x-axis.
Question 3. [10 marks for the whole question] Illumination Models
The following figure (Fig. 3) gives the components of unit vectors used for lighting calculations at a point P on a sphere, and also the ambient, diffuse, specular properties of the light L and the sphere material (l = light source vector, n = normal vector, v = view vector, r = reflection vector). Assume that L is the only light source in the scene.
(4, 3, 1)
Consider the triangle shown in Fig. 2. The vertex coordinates of the triangle are given in the figure.
f (Phong’s constant) = 10.
Light’s properties: La = (0.2, 0.2, 0.2) Ld = (1, 1, 1)
Ls = (1, 1, 1)
30 Sphere
Material properties:
Ma = (0, 1, 1) Md = (0, 1, 1) Ms = (1, 1, 1)
(a) (2 Marks) Write the colour components of the net reflection from the vertex Q.
(b) (3 Marks) Write the mathematical expression for the colour of the diffuse reflection at vertex
P, and compute the numerical values of its components.
Page 4 of 8
Mid-year Examinations, 2019 COSC363-19S1 (C)
(c) (3 Marks) Write the mathematical expression for the colour of specular reflection (including the shininess term) at P along the view direction v, and compute the numerical values of the colour components.
(d) (2 Marks) Write the expression for the half-way vector at P, and also the modified formula for computing the specular reflection using the half-way vector. You are not required to perform any numerical calculation for this question.
Question 4. [12 marks for the whole question] Texture Mapping
The polygonal object shown in Fig.4a is created using a quad-strip {A1, A2, B1, B2, C1, C2, D1, D2}. The top side consists of two triangles A2B2P, C2D2Q and a quad PB2C2Q. Consider the texture image of size NxN pixels given in Fig. 4b.
A2 P Q B2 C2
B1 C1 Fig. 4a.
(a) (8 Marks) Write the texture coordinates (s, t) that must be assigned to the vertices, so that the quad-strip displays 5 repetitions of the horse image distributed evenly across the three segments; and the quad PB2C2Q on the top displays the disc (Fig. 4c). Assume that the texture wrap mode is set to GL_REPEAT along s and t. Please provide your answer in the answer-booklet in the following format:
Quad-strip A1
B2 C1 C2 D1 D2
Quad s t P
Page 5 of 8
Mid-year Examinations, 2019 COSC363-19S1 (C)
(b) (4 Marks) Briefly describe (in 3 or 4 sentences) what is meant by “mipmapping”, and its usefulness in texture mapping. You are not required to give any equations.
Question 5. [10 marks for the whole question] View Transformation y
A teapot is placed at position T on the x-axis at a distance of 40 units from the origin, as shown in Fig. 5a. The camera is placed at a fixed position C along the y-axis at a height of 30 units.
(a) (2 Marks) Write the parameter values of the camera function gluLookAt(ex, ey, ez, lx, ly, lz, ux, uy, uz), that places the teapot along the view axis of the camera and generates an output similar to that given in Fig. 5c.
(b) (3 Marks) Redraw the triangle in Fig 5b in your answer booklet and mark the directions of the camera axes xe, ye, ze (eye coordinate frame) at C, where the view axis of the camera is along CT. Indicate an out-of-plane axis with a dashed line.
(c) (2 Marks) The camera is rotated by 180 degrees at position C, keeping the view direction fixed, to generate the output given in Fig. 5d. Write the parameter values of the function gluLookAt(…) for this configuration.
(d) (3 Marks). The teapot is at a distance of 50 units from the camera. Write the coordinates of T and C in both the world coordinate frame and the eye coordinate frame for the camera configuration given in Q.5(a).
Question 6. [10 marks for the whole question] Projection Transformation A view frustum is specified using the following statement:
glFrustum(-50.0, 50., -30., 30., 50.0, 100.0);
(a) (6 Marks) Draw a sketch of the view frustum, clearly showing what each of the six parameters of the above function represents. The figure should also show the camera position, camera coordinate axes directions, and the view axis direction.
(b) (4 Marks) Using the parameters of the function, compute the aspect ratio of the near plane, and the field of view along the y-direction.
Page 6 of 8
Mid-year Examinations, 2019
COSC363-19S1 (C)
Question 7. [16 marks for the whole question]
2 Fig. 6a
(a) (3 Marks) Fig. 6a shows the refraction of an incident ray d through a sphere. The normal vectors are indicated by dashed lines. The refractive indices of the two mediums are also shown. You are given the function refract(d, n, eta) that returns the direction of the refracted ray, given the direction of the incoming ray ‘d’, and the surface normal direction ‘n’ at the point of intersection directed towards the incident ray’s medium. Write the function statements with appropriate parameters required to compute the outgoing ray’s direction h. For each refracted ray, give the expression for ‘eta’ as a ratio of refractive indices.
(b) (3 Marks) Refer to Fig. 6b. A shadow ray is traced from a point P towards a light source L, and intersects a sphere at Q. Write the conditions to be satisfied by Q in order that the point P is in shadow. Assume that the ray does not intersect any other object.
(c) (6 Marks) The points of intersection of the ray p = P + td and a sphere centered at a point C with radius r is given by
t(sd) (sd)2 (ss)r2 , where s=PC.
If P=(2,1,2), C=(10,7,2), d=(0.8,0.6,0), and r=4,computethevaluesoftheray
intersection parameter t using the above formula.
(d) (2 Marks) With reference to the previous question Q7(c), write the coordinates of the point of
intersection on the sphere that lies closest to P.
(e) (2 Marks). Give a geometrical interpretation of the parameters t, s used in the equation given in
Question 8. [15 marks for the whole question] OpenGL Shaders
(a) (4 Marks) Briefly describe two important operations performed in a vertex shader and in a tessellation control shader.
Shadow ray
Page 7 of 8
Mid-year Examinations, 2019 COSC363-19S1 (C)
(b) (6 Marks) A quad domain is tessellated as shown in the figure above (Fig. 7). Write the inner and outer tessellation levels used in generating the figure, and also give the tessellation coordinates of the points A, B, C and D.
(c) (5 Marks) A part of a tessellation evaluation shader is shown below.
void main() {
float u = gl_TessCoord.x;
float v = gl_TessCoord.y;
posn = (1-u)* (1-v) * gl_in[0].gl_Position
+ u * (1-v) *
+ (1-u) * v *
gl_in[1].gl_Position
gl_in[2].gl_Position
gl_in[3].gl_Position;
gl_Position = mvpMatrix * posn;
Give a brief description of each of the four statements in the above code segment, explaining themeaningsofthevariablesgl_TessCoord, gl_in[].gl_Position, posn, and gl_Position.
End of Examination
Page 8 of 8
程序代写 CS代考 加微信: cscodehelp QQ: 2235208643 Email: kyit630461@163.com