Spring 2006 CSIE 922 U0110, Programming Assignment #2
|
Assigned
|
Mar 23, 2006 |
|
Due Date
|
Apr 6, 2006 by 24:00 PM |
Supporting lines of and intersection with a convex polygon
Part I: Given a convex polygon G and a query point q, output the two (left and right) supporting lines through q if q is not inside the polygon. A line is a supporting line of G if the line passes through at least one point of G and all other points lie on one side of the line. A directed supporting line from q to v, where v is a vertex of G, is a left supporting line, if all the points of G lie to the right of the directed line, and is a right supporting line, if all the points of G lie to the left of it.
Part II: Given a convex polygon G and a query line L, determine if the line L intersects G. If it does, reply with a 'YES' message and find the points of G that it intersects. Else reply with a 'NO' message.
Bonus: Allow the user to enter a point list, computer the convex hull G and then use it as input to the problem.
Output: Two (directed) supporting lines through q if q is not inside G. Else display a message "The query point is inside G."
This assignment is designed for you to implement the bimodal search method. Notice that you need not explicitly compute all the function values, f(0), f(1),¡K, f(n-1) for vertices v0, v1, ¡K, vn-1 of G. Instead you compute the function values, as needed. Your program should be written in C/C++ using object classes available in the library or new objects developed on your own. Documentation of your code is necessary. In addition to the running code, you must include the pseudo-code, and give the timing analysis of your algorithm. Note that the brute force algorithm is not allowed.