public class ConvexHull extends Object
Given a set of points, a convex hull is the smallest convex region that contains all the points.
Constructor and Description |
---|
ConvexHull(double[] xvals,
double[] yvals)
Instantiate a ConvexHull object and call quickHull on the given
set of points.
|
Modifier and Type | Method and Description |
---|---|
double |
getArea()
Return the area of the convex hull.
|
double |
getPerimeter()
Return the perimeter of this convex hull.
|
Iterator |
points()
Return an iterator over the points (Point2D) in the convex hull.
|
void |
quickHull(double[] xpath,
double[] ypath)
Quickhull algorithm is similar to Quicksort algorithm.
|
public ConvexHull(double[] xvals, double[] yvals)
public double getArea()
public double getPerimeter()
public Iterator points()
public void quickHull(double[] xpath, double[] ypath)
In the algorithm, we first pick two points, the left most (min x) and the right most (max x). These two points (obviously lie on the hull) form a split line separating the region into two. Then we recursively split each region by finding the point that's the farthest from the split line.
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.