*Answers in BLUE*

# Homework 5, due Thurs Oct 4 Solution

Hand in your solution on RPILMS. Each team should submit their solution under only 1 student's name. The other student's submission should just name the lead student. (This makes it easier for us to avoid grading it twice.) For programming exercises, hand in code and screen dumps. We won't run your code, but will use the screendumps to judge how it worked.

This homework has no programming. Use any tool that you wish for the multiplications, e.g., Matlab. Include a copy of the relevant part of the session.

1. *(2 pts)* Write the 4x4 matrix for a translation by (0,3,1).

{$$\left(\begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 3 \\ 0 & 0 & 1 & 1 \\ 0 & 0 & 0 & 1 \end{array}\right)$$}

2. *(2)* Apply it to the 3D point (1,0,1).

(1,3,2).

3. *(2)* Write the 4x4 matrix for a multiplication about the Y axis by 90 degrees.

{$$\left(\begin{array}{cccc} 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ -1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{array}\right)$$}

4. *(2)* Apply it to the answer from question 2.

(2,3,-1,1) or (2,3,1).

5. *(2)* Multiply the matrices that are the answers to questions 1 and 3, with 1 being on the right.

{$$\left(\begin{array}{cccc} 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 3 \\ -1 & 0 & 0 & 1 \\ 0 & 0 & 0 & 1 \end{array}\right)$$}

6. *(2)* Apply that matrix to the point (1,0,1). The answer should be the same as question 4.

(2,3,-1,1) or (2,3,1).

7. *(2)* Why is it useful that translation be a matrix multiplication?

So you can combine it with other transformations that are matrices, so make one matrix that you apply to all the points. It's faster.

8. *(2)* Two ways to animate are to use an idle callback and a timer callback. (Since we haven't discussed these in class, you will need to research them.) One of these is more likely to give the same animation when run on a machine that is faster and has a higher refresh rate. Which is it and why?

The timer callback because it executes after a given specific time, not when there are spare cycles.

9. *(2)* Suppose that you specify two colors before drawing a point thus:

glColor3f(1.,0.,1.); glColor3f(0.,1.,0.); glVertex3f(10.,20.,30.);

What color is the point? E.g, do the magenta and green mix to make the point white?

The most recent color applies, that is, green.

10. *(2)* Suppose the you draw a second point w/o specifying the color again. What color is this point? E.g., does it revert to black?

The most recent color still applies, that is, green.

11. *(2)* (Reverse engineering rotations) In 2D, if the point (2,-1) rotates about the origin to (1,2), what's the angle?

I showed several ways on 1010.pdf. 90 degrees.

*Total: 22*