|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.sketch.features.ConvexHull
public class ConvexHull
A ConvexHull object implements the Quickhull algorithm to find the planar convex hull of a set of points.
Given a set of points, a convex hull is the smallest convex region that contains all the points.
Constructor Summary | |
---|---|
ConvexHull(double[] xvals,
double[] yvals)
Instantiate a ConvexHull object and call quickHull on the given set of points. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConvexHull(double[] xvals, double[] yvals)
Method Detail |
---|
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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |