Top Description Constructors Methods
org.apache.commons.math3.geometry.euclidean.twod.hull

public final Class AklToussaintHeuristic

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collection, .List, org.apache.commons.math3.geometry.euclidean.twod.Vector2D

A simple heuristic to improve the performance of convex hull algorithms.

The heuristic is based on the idea of a convex quadrilateral, which is formed by four points with the lowest and highest x / y coordinates. Any point that lies inside this quadrilateral can not be part of the convex hull and can thus be safely discarded before generating the convex hull itself.

The complexity of the operation is O(n), and may greatly improve the time it takes to construct the convex hull afterwards, depending on the point distribution.

Since
3.3
See Also
Akl-Toussaint heuristic (Wikipedia)

Constructor Summary

AccessConstructor and Description
private
AklToussaintHeuristic()

Hide utility constructor.

Method Summary

Modifier and TypeMethod and Description
private static List<Vector2D>

Returns:

the quadrilateral
buildQuadrilateral
(final Vector2D...
the respective points with min/max x/y coordinate
points
)

Build the convex quadrilateral with the found corner points (with min/max x/y coordinates).

private static boolean

Returns:

true if the point is inside the quadrilateral, false otherwise
insideQuadrilateral
(final Vector2D
the point to check
point
,
final List<Vector2D>
the convex quadrilateral, represented by 4 points
quadrilateralPoints
)

Checks if the given point is located within the convex quadrilateral.

public static Collection<Vector2D>

Returns:

a reduced point set, useful as input for convex hull algorithms
reducePoints
(final Collection<Vector2D>
the original point set
points
)

Returns a point set that is reduced by all points for which it is safe to assume that they are not part of the convex hull.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AklToussaintHeuristicback to summary
private AklToussaintHeuristic()

Hide utility constructor.

Method Detail

buildQuadrilateralback to summary
private static List<Vector2D> buildQuadrilateral(final Vector2D... points)

Build the convex quadrilateral with the found corner points (with min/max x/y coordinates).

Parameters
points:Vector2D[]

the respective points with min/max x/y coordinate

Returns:List<Vector2D>

the quadrilateral

insideQuadrilateralback to summary
private static boolean insideQuadrilateral(final Vector2D point, final List<Vector2D> quadrilateralPoints)

Checks if the given point is located within the convex quadrilateral.

Parameters
point:Vector2D

the point to check

quadrilateralPoints:List<Vector2D>

the convex quadrilateral, represented by 4 points

Returns:boolean

true if the point is inside the quadrilateral, false otherwise

reducePointsback to summary
public static Collection<Vector2D> reducePoints(final Collection<Vector2D> points)

Returns a point set that is reduced by all points for which it is safe to assume that they are not part of the convex hull.

Parameters
points:Collection<Vector2D>

the original point set

Returns:Collection<Vector2D>

a reduced point set, useful as input for convex hull algorithms