CS 418: Homework #2 Solutions, Assignments of Computer Graphics

The solutions to homework #2 for cs 418. It includes questions on quaternions, transformation matrices, computer graphics, and animation. Students are expected to write clearly and legibly, and to label their answers with the corresponding question.

Typology: Assignments

Pre 2010

Uploaded on 03/10/2009

koofers-user-f8r-1
koofers-user-f8r-1 🇺🇸

5

(2)

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 418: Homework #2
Assigned: Friday October 1, 2004
Due: Thursday October 7, 2004 at the end of class
Please be organized when writing your answers to these questions. Make sure that all solutions are clearly indicated
and labelled with the question they are answering. Remember to write clearly and legibly. Unreadable answers will
receive 0 credit.
1. (20pt) You are given two quaternions, q1=2
2+2
2kand q2=i+j+k.
(a) What is the norm of q1?
(b) What is the inverse of q1?
(c) Compute q1q2and q2q1. Are they equal ?
(d) q1represents a rotation. What are the rotation axis and angle ?
2. (10pt) Suppose you are given the 4×4transformation matrix
M=
cos θ000
0 cos θ0 0
0 0 cos θ0
0 0 0 cos θ
For a given value of θ, describe the geometric effect of applying this transformation to a torus. (You may assume
that cos θ6= 0.)
3. (20pt) Harvey has written some code to draw the following unit cylinder:
y
z
{
{
radius
r = 1
height
h = 1
x
His drawing code places vertices along the upper and lower rims of the cylinder, connecting them together with
triangles which stretch the entire length of the cylinder. He draws the cylinder using a shiny material. Given the
position of the light, he expects to see a specular highlight in the middle of the cylinder.
(a) When Harvey executes his OpenGL code (using Gouraud shading) no highlight appears in the middle of the
cylinder. However, when he renders it with RenderMan (using Phong shading) the highlight appears. Explain
why this is.
pf2

Partial preview of the text

Download CS 418: Homework #2 Solutions and more Assignments Computer Graphics in PDF only on Docsity!

CS 418: Homework

Assigned : Friday October 1, 2004

Due : Thursday October 7, 2004 at the end of class

Please be organized when writing your answers to these questions. Make sure that all solutions are clearly indicated and labelled with the question they are answering. Remember to write clearly and legibly. Unreadable answers will receive 0 credit.

  1. (20pt) You are given two quaternions, q 1 =

√ 2 2 +^

√ 2 2 k^ and^ q^2 =^ i^ +^ j^ +^ k. (a) What is the norm of q 1? (b) What is the inverse of q 1? (c) Compute q 1 q 2 and q 2 q 1. Are they equal? (d) q 1 represents a rotation. What are the rotation axis and angle?

  1. (10pt) Suppose you are given the 4 × 4 transformation matrix

M =

cos θ 0 0 0 0 cos θ 0 0 0 0 cos θ 0 0 0 0 cos θ

For a given value of θ, describe the geometric effect of applying this transformation to a torus. (You may assume that cos θ 6 = 0.)

  1. (20pt) Harvey has written some code to draw the following unit cylinder:

y

z

radius

r = 1

height

h = 1

x

His drawing code places vertices along the upper and lower rims of the cylinder, connecting them together with triangles which stretch the entire length of the cylinder. He draws the cylinder using a shiny material. Given the position of the light, he expects to see a specular highlight in the middle of the cylinder. (a) When Harvey executes his OpenGL code (using Gouraud shading) no highlight appears in the middle of the cylinder. However, when he renders it with RenderMan (using Phong shading) the highlight appears. Explain why this is.

(b) How could the OpenGL code be altered (still using Gouraud shading) so that the highlight would appear?

  1. (20pt) Suppose we use a pinhole camera to take a picture of a real rectangular carpet, and the picture covers the entire carpet. Note that the carpet may become a quadrilateral in the picture because of perspective projection. The resolution of the picture is 640x480. The pixel locations of the four corners of the carpet in the picture are (x 1 , y 1 ), (x 2 , y 2 ), (x 3 , y 3 ), (x 4 , y 4 ). Later we produce a 3D virtual model of the carpet as a rectangle in the world coordinate system and render it using texture mapping in OpenGL. We would like to use the picture as the texture image. (a) How can we obtain the texture coordinates for the corners of the carpet so that the texture-mapped carpet looks like the original one? (b) Is it possible that the edges of the carpet become curved in the picture? Why?
  2. (30pt) Suppose that we are building a model of a propellor-driven airplane that we can use in an exciting new animation. Each propellor will be modelled as a planar object made out of ellipses, as shown below:

w

h c

θ

You have decided to provide two “control knobs” to the animator using this model: the center of the propellor (c) and the angle by which the blades are rotated about this center (θ). Each of the four blades is an ellipse, as shown on the right. (a) Construct a transformation hierarchy for the object pictured above. The only geometric primitive you may use is a circle of radius 1 centered about the origin. Your hierarchy may only contain transformation nodes and geometry nodes that draw unit circles. For all transformation nodes, clearly indicate what transformation is being performed. [Hint: All your geometry nodes must be at the leaves of the tree.] (b) Suppose we define two key frames for this propellor, one at time t with rotation angle θt and the other at time t + 1 with rotation angle θt+1 (θt+1 − θt < 2 π). We would like to generate two intermediate frames (at time t + 13 and time t + 23 , respectively) between these two key frames using linear interpolation of the angle. Please write down the rotation angles for these two intermediate frames. (c) Suppose the propellor linearly accelerates from 0 to N rotations/second in one second. We draw the propellor at n frames/second. That means we need to draw n frames during the acceleration. Please describe how to obtain the rotation angle for the i-th frame, 1 ≤ i ≤ n. You can assume the first frame is drawn at time (^) n^1.

Page 2