(Geometry: Graham's algorithm for finding a convex hull) Section 22.10.2 introduced Graham's algorithm for finding a convex hull for a set of points. Assume that the Java's coordinate system is used for the points. Implement the algorithm using the following method:
/*t Return the points that form a convex hu17 */ public static Arraylist<MyPoint> getConvexHul1(double[][] s)
MyPoint is a static inner class defined as follows:
private static class MyPoint implements Comparable<MyPoint> \{ double $x, y$;
MyPoint rightMostLowestPoint;
MyPoint(double $x$, double $y$ ) \{ \} this. $x=x$; this. $y=y$;
public void setRightMostLowestPoint(MyPoint p) \{ \} rightMostLowestPoint $=p$;
Goverride
public int compareTo(MyPoint o) \{
// Implement it to compare this point with point o
// angularly along the $x$-axis with rightMostlowestPoint $/ /$ as the center, as shown in Figure 22.10b. By implementing // the Comparable interface, you can use the Array.sort // method to sort the potnts to stmplify coding.
\}
\}
Write a test program that prompts the user to enter the set size and the points and displays the points that form a convex hull. Here is a sample run:FIGURE CANT COPY