@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 GrahamScanConvexHull2D extends Object
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
GrahamScanConvexHull2D()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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 int |
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.
|
private DoubleMinMax minmaxX
private DoubleMinMax minmaxY
private boolean ok
private double factor
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 vectorprivate final double getRY(Vector a, Vector origin)
a
- origin
- origin vectorprotected final int isLeft(Vector a, Vector b, Vector o)
a
- Vector Ab
- Vector Bo
- Origin vectorprivate double mdist(Vector a, Vector b)
a
- Vector Ab
- Vector Bprivate final boolean isConvex(Vector a, Vector b, Vector c)
a
- Vector Ab
- Vector Bc
- Vector Cprivate void grahamScan()
public Polygon getHull()
Copyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.