UML CS Advanced Algorithms (Computational Geometry) 91.504 Spring, 2004 Homework Set #1 Assigned: Wednesday, 1/28 Due: Monday, 2/9 at start of lecture This assignment covers: O’Rourke textbook material in Chapter 1 Introduction to LEDA 1. (20 points) p. 42, Exercise 1.6.8 (2) Convex. 2. (20 points) p. 42, Exercise 1.6.8 (3) Spiral. 3. (20 points) Compile and run the triangulation code that accompanies the O’Rourke textbook. This can be found on our course web site under Homework. Run it for a polygon whose vertex list is: <(3,0), (2,3), (3,5), (5,2), (6,4), (2,8), (0,5)>. The program generates as output a PostScript file containing a picture of the polygon together with its triangulation. You may either print out the PostScript file on a PostScript enabled printer and submit the paper printout or email the PostScript file to Prof. Daniels. It is recommended that you create an input file for the vertex list. Sample input files are on our course web site; their filenames are of the form “i.xx”. 4. (40 points) Write a LEDA program that creates a polygon and then iterates through the vertex list, printing out the coordinates of each vertex. The program must be run on the research machine named minkowski. Test your program on the vertex list of Problem 3. We recommend that you experiment with the different LEDA loop macros for list iteration, such as forall_items and forall. A sample UNIX makefile can be found on our course web site under Homework. You will need to execute the following UNIX setenv commands prior to making and running your executable: setenv LEDAROOTI /usr/local/LEDA-4.3.1/incl setenv LEDAROOTL /usr/local/LEDA-4.3.1/ setenv LD_LIBRARY_PATH /usr/local/lib:/usr/local/LEDA-4.3.1 It is suggested that you add the above 3 statements to your local.login file. Put the following 3 statements at the start of your main.C file: UML CS Advanced Algorithms (Computational Geometry) 91.504 Spring, 2004 #ifdef LEDA_PREFIX #undef LEDA_PREFIX #endif You may choose whether or not you want to use the LEDA rational kernel. If you want to use it you need to add –D_RATKERNEL_ to your makefile. It is recommended that you write your code to be kernel independent. We also suggest that you explicitly use the LEDA prefix when you use most of the LEDA data types to avoid confusion with types in other libraries (such as CGAL or the C++ STL). Both of these goals can be accomplished by using leda_point instead of point, leda_polygon instead of polygon, and leda_list instead of list. You do not need a leda_ prefix when using LEDA’s list_item type. Extra Credit: p. 15, Exercise 1.2.5 (4) Number of different triangulations. (Hint: The 91.503 textbook (Rivest, et al.) alludes to the answer in several places…)