Question
Brute-Force convex hull: (a) Implement the brute force algorithm described in class to compute the convex hull of a set of points in 2D space.
Brute-Force convex hull:
(a) Implement the brute force algorithm described in class to compute the convex hull of a set of points in 2D space. Create a method that takes an ArrayList of Point objects (java Point class can be used) and returns an ArrayList of points on the convex hull.
(b) Verify running time by generating arrays of Point objects of varying sizes. The points should have a random x and y coordinate values. Hints:
To verify that your implementation is correct, test your code by drawing the points of the input array using StdDraw. You can then draw the points of the convex hull with a different color. The code for this can be used for problem 3 as well. (note that you don't need to draw the output when you are trying to determine running time since the arrays will be of large size).
In order to determine if vectors between three points p1, p2, p3 are a left turn, you can use the following pseudocode (to determine if points form a right turn the value of the cross product will be negative): isLeftTurn(Point p1, Point p2, Point p3) v1x = p2.x - p1.x v1y = p2.y - p1.y v2x = p3.x - p2.x v2y = p3.y - p2.y return v1x * v2y - v1y * v2x > 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started