The convex hull of a set of points is the set of points which induce the smallest convest polygon around the points of the set. There are many different mechanisms for solving the convex hull problem, but one of the most efficient algorithms (in amortized analysis) is known as Quick Hull. This algorithm is innately recursive, and is probably the easiest algorithm to implement in ML.
Write a function
quick_hull: (real * real) list -> (real * real) list
.
This function takes a list of tuples representing 2-d cartesian
coordinates, and returns a list of tuples representing 2-d cartesian
coordinates. This function should return the list of points that
are on the convex hull of the input set of points.
You may write any additional functions you need to solve the problem. However, for each function you write you must include a comment explaining the purpose of the function. For example, the comment for the above function could be "Returns the list of points on the convex hull of the input list of points".
The Quick Hull algorithm is an inherently recursive definition that relies on the fact that certain points can be computed that MUST be on the convex hull. At a broad level, the algorithm involves:
Your programs will be graded on a scale split across both functionality (80%) and style (20%). Style points are earned from proper documentation (described above) and appropriate use of pattern-matching and the built in curried functions. If a function could be written using fold and/or map, you should use these functions. If a function could be written using pattern matching, you should also use this technique.
Submit your .sml
file to inquire by
Feb. 19th, 2016.
Assignments are to be done individually. You may ask class members, lab assistants, and others for help with system questions (e.g., "How do I start the ML interpreter?" or "How do I get a printout of my program?") or general information about a topic covered in class (e.g. "What is the symbol for boolean AND?") provided you can do so without divulging or receiving information specific to the solution of the assignment problem. You may not discuss any aspect of the design or coding of a program with anyone except the instructor. See the syllabus for more information.