## Description

Assignment Objectives:

• Familiarization with transformation

• Familiarization with vectors and vector operations

• Familiarization with object modelling

• Familiarization with hierarchical object

• Familiarization with interactive graphics

Grades:

1. Assignment total marks: 100.

2. You can receive a 10 points bonus if you correctly complete the bonus section.

Submissions

1. Part 1 – a pdf file with the answers to Part 1. The file should be clearly marked as part-1.pdf. If you

are writing on a paper, try write very clear, otherwise you may not get marked if it is not readable

for TAs.

2. Part 2 –

• A zip file of the project containing the code for Part 2. The file should be clearly marked as

part-2.zip.

• A short report containing two images showing how the sphere is oriented and that it rotates.

3. Part 2 –

• A zip file of the project containing the code for Part 3. The file should be clearly marked as

part-3.zip.

• A short report containing two images showing the complex object and it is moved in space.

4. Bonus question

• A zip file of the project containing the code for Part 4. The file should be clearly marked as

part-4.zip.

• A short report containing two-images showing the different configuration of the complex object.

1

Figure 1: Illustration of the javelin hitting the shield

1 (50 points) Theory questions: Using vector operations and Transformations

1. (5 points) Given a point P = (Px, Py, Pz) and an object, O = (Ox, Oy, Oz),

1.1. Show the matrices used when computing the rotation O around P by angle α. The rotation is

around the X-axis.

1.2. What is the result when P = (1, 2, 3), O = (6, 5, 4) and α = 30o

. The rotation is around the

X-axis.

2. (3 points) Given two vectors v =< 4, 3, 2 > and u =< 5, 1, 7 >, find the angle between the two

vectors.

3. (8 points) What is the geometry matrix for this spline function? P(t) =

x(t)

y(t)

where x(t) = 2t

3 + 3t

2 − 6t + 1 and y(t) = 3t

3 − 4t

2 + 3t − 1.

4. (7 points) Given a triangle T p0 = (1, 1, 1); p1 = (−1, −1, −1); p2 = (−1, 1, −1);

1. Find the normal to the triangle. Assume that the triangle is given clockwise. Normalize the

vector. Draw a figure showing that your normal is correct.

2. Find the angle that is adjacent to p0.

3. Determine the area of the T

5. (8 points) A heroine is carrying a triangular shield as a protection from a javelin that was thrown

at her. The shield is designed to protect against any projectile that hit the shield at an angle of 60

degrees or less with respect to the shield surface, α ≤ 60 (α is the angle between the shield and the

javelin). The javelin velocity (towards the target) is v =< 0, −12, 11 > and it has hit the shield at

p = (px, py, pz). The shields coordinates are s0 = (5, 1, 0), s1 = (5, 2, 5) and s2 = (10, 3, 10). Figure 1

illustrates the question.

Determine whether the shield will protect the heroine. Show your work.

6. (7 points) Find the transformation matrix which is required to rotate an object around the vector

(p1 − p0) where p0 = (1, 1, 1) and p1 = (2, 3, 4). Show your work.

7. (6 points) Write an expression for the matrix that transforms the box drawn on the left to the box

on the right.

2

8. (6 points) The matrix that converts a perspective view frustum to a canonical viewing volume is

provided below. What is the geometric interpretation for each parameter (draw a picture)?

Pre-processing

• Download the assignment code

• Compile and link the code – you should see a rotating sphere, a rotating cylinder, and a rotating

cube.

• Familiarize yourself with the code. Review how a cylinder and a sphere are created and used.

2 (10 points) Part 2 – Render a sphere

Purpose:

• View a simple 3D object.

• Experiment with model space transformation

• Familiarization with provided code

To do:

Create a project and modify code.

1. Modify the sphere to be at position 100, 10, 100.

2. Set up a view position (e.g., 200,200,200) and the look at vector to 100, 10, 100 (centre of sphere).

3

3. The sphere is rotating around the y-axis. The rate of rotation is 0.1 degree per time step. Note that

the sphere is contracted along the y-axis.

4. Set up the sphere so that it rotates similarly to the earth (66.5 degrees). Determine which axis you

need to rotate around.

5. Display the sphere.

3 (40 points)Part 3 – Create a simple complex object (hierarchical

object)

Purpose:

• Create hierarchical object

• Use keyboard commands

• Use transformations

To do:

Create a simple hierarchical object and place it beside the sphere from Task 1 (Figure 2).

1. The object consists of a box and two spheres, where the spheres are placed on top of the box (Figure

2). Randomly set the three primary colours to the vertices (so that you can see the spheres rotating).

Use the cylinder code to create the box and scale it in the required directions.

2. One sphere should rotate counter clock wise around the y-axis (CCW) at a rate of 0.1

o per frame

(about 3o per second).

3. The second sphere should rotate around the y-axis clock wise (CW) at a rate of 0.2

o per frame (about

6

o per second).

4. The user can move the cylinder in the xz plane by using the i, j, k, l keyboard strokes –

(a) Pressing on i means translate the object by a small delta (e.g., 1) x along the x–axis = x –delta;

(b) Pressing on l means translate the object by a small delta (e.g., 1) along the x-axis x = x +

delta;

(c) Pressing on j means translate the object by a small delta (e.g., 1) along the z-axis z = z –delta;

(d) Pressing on k means translate the object by a small delta (e.g., 1) along the z-axis z = z +

delta;

4 (10 points) Part 4 – Render a “robot arm” complex hierarchical object (bonus)

Purpose:

• Create a more complex hierarchical object

• Use keyboard commands

4

Figure 2: Simple hierarchical object

• Experiment with the simplicity of hierarchical objects

To do:

1. Create a simple “robot arm” (hierarchical object) as follows:

1.1. The object consists of 3 cylinders and 2 spheres (Figure 3).

2. The user can identify each of the parts using the numeric keys 1, 2, 3, 4, 5. Figure 2 shows how the

parts and their ids.

3. The user can manipulate the objects as follows (note all rotations are with respect to the model

object):

3.1. The user selects an object part using a numeric key 1-5

3.2. Action for cylindrical parts (id – 1, 3, 5)

3.2.1. Once a part is selected the user can rotate the object as follows: rotate the part using keys z

and x around the y-axis (yaw rotation) by +1 or -1 degree, respectively. See the orange arrows.

3.3. Action for spherical parts (id – 2, 4).

3.1. Once a part is selected the user can rotate the object as follows: rotate the part using keys z

and x around the x-axis (pitch rotation) by +1 or -1 degree, respectively. See the black arrow

4. Note that you may have to adjust the orientation of the box to ensure correct operation.

Figure 3: Robot arm manipulator

5