{VERSION 2 3 "APPLE_68K_MAC" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 265 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 266 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 267 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 268 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 269 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 270 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 271 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 272 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 273 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 274 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 275 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 276 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 } {CSTYLE "" -1 277 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 256 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 257 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 258 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {PARA 256 "" 0 "" {TEXT -1 39 "Lighting and Three Dimensional \+ Graphics" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 293 "This Maple worksheet will enable you to reproduce pictures like t he ones drawn by the Java applets you've already looked at. The Java \+ applets work with a sphere but later you will be able to use Maple and little more mathematics to work with other surfaces -- for example, \+ saddles and cones." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 321 "The cell below is the most important cell in this worksh eet. This is the cell that you will change to work with specular shad ing rather than Lambertian shading and to work with three different co lored light sources rather than one single white light source. This c ell is a function that defines the shading of one point" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 257 "" 0 "" {TEXT -1 10 "P = (x, y)" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 60 "on the sp here when the light is coming from the direction, " }{TEXT 256 17 "V \+ = (vx, vy, vz)." }{TEXT -1 15 " The vector " }{TEXT 257 1 "V" } {TEXT -1 40 " must be a unit vector and the vector " }{TEXT 258 1 "P " }{TEXT -1 38 " must have length less or equal to 1." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 200 "Before going on, lo ok at this cell and understand what it is doing mathematically -- that is, how the shading is determined mathematically. Recall that colors are described by a statement of the form" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 258 "" 0 "" {TEXT -1 28 "color(RGB, red, green, blue)" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 6 "where " } {TEXT 259 3 "red" }{TEXT -1 2 ", " }{TEXT 260 5 "green" }{TEXT -1 6 ", and " }{TEXT 261 4 "blue" }{TEXT -1 13 " are between " }{TEXT 262 1 " 0" }{TEXT -1 5 " and " }{TEXT 263 1 "1" }{TEXT -1 85 " and specify the amounts of red, green, and blue, respectively making up the color. \+ " }{TEXT 264 18 "color(RGB, 0, 0, 0" }{TEXT -1 15 ") is black and " } {TEXT 265 18 "color(RGB, 1, 1, 1" }{TEXT -1 15 ") is white. \n\n" } {TEXT 266 72 "Now, after you understand the mathematics in the cell be low evaluate it." }}{PARA 0 "" 0 "" {TEXT -1 1 " " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 241 "ColorAt := \+ proc(x, y)\n local z, intensity:\n z := sqrt (1 - x*x - y*y):\n intensity := evalf(x * vx + y * vy + z * vz):\n COLOR(RGB, intensity, intensity, intensity):\n \+ end: " }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 106 "The next cell draws the sphere with Lambertian s hading. There are several parameters that you can change." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 267 2 "vx" }{TEXT -1 5 " and " }{TEXT 268 2 "vy" }{TEXT -1 145 " -- the two parameters that de fine the x and y coordinates of the direction from which the light is \+ coming. The cell computes the z coordiante, " }{TEXT 269 2 "vz" } {TEXT -1 22 ", using the fact that " }{TEXT 270 1 "V" }{TEXT -1 23 " m ust be a unit vector." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 271 1 "n" }{TEXT -1 69 " -- the number of rows and columns in the image of the sphere. When " }{TEXT 272 1 "n" }{TEXT -1 189 " is \+ fairly big (20 in the original cell) the quality of the image is fairl y good but the cell can take a long time to evaluate. When you are ex perimenting with changes you may want to set " }{TEXT 273 1 "n" } {TEXT -1 235 " to a smaller number -- perhaps 10 -- in the interests o f speed. Then when you want to look at a higher quality image you can set it back to 20. For an even higher quality image or if your compu ter is very fast you might try setting " }{TEXT 274 1 "n" }{TEXT -1 9 " to 40. " }{TEXT 275 32 "Evaluate the following cell now." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 767 "v x := 0.0: # x-coordinate of light source.\nv y := 0.0: # y-coordinate of light source.\n \nvz := sqrt(1 - vx * vx - vy * vy): # z-coordinate of light source. \n\nn := 20: # controls resolution.\n\nsha de := proc(x, y)\n if (x*x + y*y >= 1.0) then\n \+ COLOR(RGB, 0, 0, 0);\n else\n ColorAt(x, y );\n fi;\n end:\n\nwith(plots):\nwith(plottools):\n \nimage := seq( seq( rectangle([(x - 0.5)/n, (y - 0.5)/n],\n \+ [(x + 0.5)/n, (y + 0.5)/n],\n \+ color = shade(x/n, y/n)),\n x = -n..n),\n \+ y = -n..n):\n\ndisplay(image, axes=none, scaling=constrained , style=patchnogrid);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 170 "You should try several experiments by modifying the cells above. Try the first two experiments first and then try additi onal experiments as you read through this module." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 118 "1. Move the single ligh t source in the cell above around so that it illuminates the sphere fr om different directions." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 145 "2. Add some diffuse lighting so that every point on the sphere is shaded with a light gray in addition to the light fr om the bare bulbs above. " }{TEXT 276 58 "Warning: The light level c an't be above 1 for each color." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 65 "3. Try Lambertian reflection with three \+ different light sources." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 55 "4. Try specular reflection with a single light so urce." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 63 " 5. Try specular reflection with three different light sources." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 145 "6. Add \+ some diffuse lighting so that every point on the sphere is shaded with a light gray in addition to the light from the bare bulbs above. " } {TEXT 277 58 "Warning: The light level can't be above 1 for each colo r." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{MARK "0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }