2. Learn how to print out the graphics image that we draw in DrScheme.
2. You will use vectors to represent points on the graphics window. Extend your copy of the file "poly.scm" (either by editing it on Strauss or loading it into DrScheme and editing the definitions area) by defining the constructor (make-vect x y) and the selectors (xcor-vect v) and (ycor-vect v) where
(xcor-vect (make-vect x y)) = x (ycor-vect (make-vect x y)) = yWith these defined, you should be able to draw a line on the graphics window. For instance, (drawline (make-vect 0 0) (make-vect 200 200)) should draw a line from the lower left corner of the window to the middle.
3. Extend the file further by defining a procedure (polygon n x y r) that draws an n-sided polygon with center at location (x,y) and with all the corners of the polygon at a distance of r from the center. Thus, (polygon 8 200 200 100) should draw an octagon that is centered in the window and is about half as wide as the window. The orientation of the polygon is not important, but it would be nice if a four-sided polygon looked like a square rather than a diamond. (The automated test program will not check for orientation.)
4. After you have tested your code and are satisfied that it draws polygons correctly, submit the code you added to "poly.scm" to the Automated Tester and click on the Confirm butten when you get a PASS. Do not include the predefined code in poly.scm; it only works in the graphics environment and the tester is running MzScheme in a command line environment. Be sure that the pasted program you submit contains your definitions of make-vect, xcor-vect, ycor-vect, polygon and any auxiliary procedures that you define. (The assigment can be easily done without any auxiliary procedures external to polygon.)
5. Using your program, draw one or more polygons on the graphics window and print the window. On a SunRay, you should be able to click on the graphics window and press Alt+PrintScreen. This will let you save the image as a PNG file on the Desktop. You can click on that file and print it out. On a PC, you should be able to click on the graphics window, press Alt+PrtSc, open Microsoft Word, click on Paste, and then print the Word file to get the image to the local printer. Show your pretty picture to the TA.
To compute the coordinates of a corner point, you will want to remember that for a circle with radius r, the vector from its center to a point on its circumference at an angle a has coordinates (r cos(a), r sin(a)). (This is math notation, not scheme notation. Both sin and cos are in MzScheme.)
The most common mistake that students made in the past is to draw the polygon in such a way that one of the sides gets drawn twice. You can't see this happening, but the tester detects it and considers it an error.