Question: Programming Exercise finds a convex hull for a set of points entered from the console. Write a program that enables the user to add/remove points
Programming Exercise finds a convex hull for a set of points entered from the console. Write a program that enables the user to add/remove points by clicking the left/right mouse button, and displays a convex hull, as shown in Figure.
Section 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:

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:
![ArrayList getConvexHull(double[]] s) MyPoint is a static inner class defined as follows:](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/11/636a73aef1e3d_814636a73aee1ae0.jpg)

** Return the points that form a convex hull */ public static ArrayList getConvexHull(double[]] s) MyPoint is a static inner class defined as follows: private static class MyPoint implements Comparable { double x, y; MyPoint rightMostLowestPoint; MyPoint(double x, double y) { this.x = x; this.y = y; public void setRightMostLowestPoint(MyPoint p) { rightMostLowestPoint = p; @Override public int compareTo(MyPoint o) { I/ Implement it to compare this point with point o Il angularly along the x-axis with rightMostLowestPoint Il as the center, as shown in Figure 22.10b. By implementing Il the Comparable interface, you can use the Array.sort Il method to sort the points to simplify coding. } How many points are in the set? 6 -Enter Enter 6 points: 1 2.4 2.5 2 1.5 34.5 5.5 6 6 2.4 5.5 9 The convex hull is Enter (1.5, 34.5) (5.5, 9.0) (6.0, 2.4) (2.5, 2.0) (1.0, 2.4)
Step by Step Solution
3.50 Rating (170 Votes )
There are 3 Steps involved in it
Program Plan Create a class convexHullAnimation which extends Application Create an inner class View ... View full answer
Get step-by-step solutions from verified subject matter experts
