|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.lmu.ifi.dbs.elki.math.ConvexHull2D
@Reference(authors="Paul Graham", title="An Efficient Algorithm for Determining the Convex Hull of a Finite Planar Set", booktitle="Information Processing Letters 1") public class ConvexHull2D
Classes to compute the convex hull of a set of points in 2D, using the classic Grahams scan. Also computes a bounding box.
Field Summary | |
---|---|
private double |
factor
Scaling factor if we have very small polygons. |
private DoubleMinMax |
minmaxX
Min/Max in X |
private DoubleMinMax |
minmaxY
Min/Max in Y |
private boolean |
ok
Flag to indicate that the hull has been computed. |
private List<Vector> |
points
The current set of points |
Constructor Summary | |
---|---|
ConvexHull2D()
Constructor. |
Method Summary | |
---|---|
void |
add(Vector point)
Add a single point to the list (this does not compute the hull!) |
private void |
computeConvexHull()
Compute the convex hull. |
private void |
findStartingPoint()
Find the starting point, and sort it to the beginning of the list. |
Polygon |
getHull()
Compute the convex hull, and return the resulting polygon. |
private double |
getRX(Vector a,
Vector origin)
Get the relative X coordinate to the origin. |
private double |
getRY(Vector a,
Vector origin)
Get the relative Y coordinate to the origin. |
private void |
grahamScan()
The actual graham scan main loop. |
private boolean |
isConvex(Vector a,
Vector b,
Vector c)
Simple convexity test. |
protected boolean |
isLeft(Vector a,
Vector b,
Vector o)
Test whether a point is left of the other wrt. the origin. |
private double |
mdist(Vector a,
Vector b)
Manhattan distance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private List<Vector> points
private DoubleMinMax minmaxX
private DoubleMinMax minmaxY
private boolean ok
private double factor
Constructor Detail |
---|
public ConvexHull2D()
Method Detail |
---|
public void add(Vector point)
point
- Point to addprivate void computeConvexHull()
private void findStartingPoint()
private final double getRX(Vector a, Vector origin)
a
- origin
- origin vector
private final double getRY(Vector a, Vector origin)
a
- origin
- origin vector
protected final boolean isLeft(Vector a, Vector b, Vector o)
a
- Vector Ab
- Vector Bo
- Origin vector
private double mdist(Vector a, Vector b)
a
- Vector Ab
- Vector B
private final boolean isConvex(Vector a, Vector b, Vector c)
a
- Vector Ab
- Vector Bc
- Vector C
private void grahamScan()
public Polygon getHull()
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |