all the questions are here now, along with the test code. PLEASE (re)read the instructions at the top and follow them carefully. penalties will be imposed for failing to follow them. sorry about the delay. - tky ############################################################################### Computer Graphics Homework 3 CS417/CS418 Fall 1998 Due Wednesday, February 24, 1999 -![2/21/99] Changes are dated and surrounded by exclamation points.!- -![2/21/99] + Hand in each question SEPARATELY. + Make sure your names are LEGIBLE and EASILY SPOTTED on the front page of each question. + As always in this class, you are graded on correctness and also clarity and conciseness. + EXACTLY ONE of you should write legibly & sign & date the following (fill blanks appropriately): ``I, ____, CUID# ____, wrote up this assignment; my partner is ____, CUID# ____.'' + E-mail how many total hours PER PERSON you spent on this homework by midnight, SUNDAY, February 28. For example, if you and your partner spend 3 hours together, you spend 2 on your own, she spends 1 on her own, then together you spent [3+3+2+1]/2 = 4.5 hours per person. Penalties will be imposed for failing to follow these instructions. !- =============================================================================== CS417 part =============================================================================== 1. Use -![2/21/99] ideas from!- raysphere to rewrite drawspheres from HW2 to do shadows. -![2/21/99] Assume that shadows are rare.!- -![2/21/99] Warning: Beware that the sample solution to raysphere assumes row vectors, but the vectors in drawspheres are column vectors.!- -![2/21/99] Turn in a listing of your code and a printout of the output from the original test scene (there should be a shadow on the red sphere *above* the green sphere).!- 2. Write a Matlab function so that [xx,yy,zz] = sweep(x,y,z,n); surf(xx,yy,zz) plots the swept surface obtained by rotating the curve (x(i),y(i),z(i)) for i=1:length(x) around the z-axis, sampled at n different angles (you will need to use n+1 angles, with one angle duplicated in order to sweep the curve all the way around.) You may assume that x,y,z are row vectors. -![2/21/99] Turn in a listing of your code and a printout of the output from sweeping the following curve around the z-axis: t = linspace(0,pi,50); r = 1 + sin(t) + sin(8*t)/5; x=r.*sin(t); y=0*t; z=r.*cos(t); !- 3. Take the Matlab test code for HW2 (the one with the SURF commands), and fix it so that there are no "defects" -- use a command like set(h,'VertexNormals',blah) to tell Matlab what the normals should be at each vertex. Also, add an orange sphere somewhere in the scene. It should partially obscure 2 spheres, and should itself be partially obscured. (You need to figure out the rgb for orange.) -![2/21/99] Turn in a listing of your code and a printout of the output.!- =============================================================================== CS418 part =============================================================================== 4. Write a Matlab function tree(position,direction,width) that draws a 2-dimensional tree using the following algorithm: if WIDTH<1 then stop else fill in a rectangle with a corner at POSITION, of the specified WIDTH, and of height 2*WIDTH, tilted by DIRECTION radians -![2/19/99] COUNTER-CLOCKWISE!- from the x-axis. choose a random angle theta in 0..pi/2 use this to fill in a -![2/21/99] right triangle!- at the head of the rectangle. recursively draw two trees end NOTE: You will find the FILL and RAND functions to be useful. -![2/21/99] Turn in a listing of your code and a printout of the output from clf; axis equal; hold on; tree([0 ; 0], pi/2, 20) note that HOLD ON tells Matlab to draw everything, instead of only the very last drawing command. You may choose the fill colors; suggestions are either always black or to choose random colors.!- 5. (Bonus) This is question is a bit open-ended. Try to give a good but brief answer. How come in HW2 the "edges" look jaggy? How come the "insides" look good? For example, how come anti-aliasing (e.g. by supersampling) isn't needed for the insides? HINT: Suppose the color at a point (x,y) were a function like x+y or x^2+y^2. How big are the "jumps" (differences) between the colors of adjacent pixels, e.g. between (x,y) and (x+1,y)? Now integrate to find the average color of a pixel; how big are the jumps now?