Computer Graphics Homework 0 CS417/CS418 Fall 1998 Due Wednesday, January 27, 1999 * This diagnostic homework will be weighted to count much less than other homeworks.* For this homework, NO PARTNERS.* Hand in each part (CS417, CS418, administrative) SEPARATELY.* As always in this class, you are graded on correctness and also clarity and conciseness. Administrative Part 0. Fill out the waiver AND e-mail the requested information AND write legibly & sign & date on your homework the following statement, filling in your own name and CUID# as appropriate: "I, hyour namei, CUID#hyour CUID#i, wrote up this assignment." You must complete this question to receive credit; e-mail will be accepted until Friday midnight. CS417 Part 1. Suppose r is a root of the polynomial x2 + bx + c, i.e. r2 + br + c = 0. Express the other root of the polynomial in terms of r, b, c using only subtraction or division -- square root and exponentiation (powers) are not allowed. HINT: Suppose the polynomial were factored into two linear terms; how are the terms related to the roots and coefficients of the polynomial? 2. Use the following formulas: cos(` + OE) = cos(`) cos(OE) - sin(`) sin(OE) (1) sin(` + OE) = sin(`) cos(OE) + cos(`) sin(OE) (2) (x, y) = (r cos(`), r sin(`)), for r = px2 + y2 and some `. (3) to derive a formula for the result (x0, y0) of rotating (x, y) clockwise ae radians around the origin. Show your work. Your final answer should involve only x, y, ae -- neither r nor ` should appear. HINT: Does the radius (distance r from the origin) change? What's the new angle? 3. Let a = (xa, ya) and b = (xb, yb) be two vectors, i.e. two points in the plane R2. (a) Give a formula for the projection c = (xc, yc) of vector a onto vector b, i.e. the point c obtained by projecting point a onto the line defined by the origin and point b. (b) Give a formula for the reflection d = (xd, yd) of vector a across vector b, i.e. the point d obtained by reflecting point a across the line defined by the origin and point b. HINT: You may use c in your answer even if you couldn't figure out its formula. CS418 Part 4. Enter type sphere at the Matlab prompt to see the code (including helpful comments) for sphere, which is useful for plotting a sphere with equally many latitude and longitude lines. Write a Matlab function mysphere so that [x,y,z] = mysphere(m,n); surf(x,y,z) plots a sphere with m latitude lines and n longitude lines. Demonstrate with m = 11 and n = 40. Turn in your code and a printout of the plot. (If you're uncomfortable writing a function, then instead write a script/sequence of commands. In this case, your code should start with m=11; n=40 and never again reference constants 11,40). HINT: Figure out the definitions of theta, phi, cosphi, and sintheta and alter these four lines of code appropriately (no other computations need to be changed).