Class AbstractConvexHullGenerator2D
java.lang.Object
org.apache.commons.math3.geometry.euclidean.twod.hull.AbstractConvexHullGenerator2D
- All Implemented Interfaces:
ConvexHullGenerator2D, ConvexHullGenerator<Euclidean2D, Vector2D>
- Direct Known Subclasses:
MonotoneChain
Abstract base class for convex hull generators in the two-dimensional euclidean space.
- Since:
- 3.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final doubleDefault value for tolerance.private final booleanIndicates if collinear points on the hull shall be present in the output.private final doubleTolerance below which points are considered identical. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractConvexHullGenerator2D(boolean includeCollinearPoints) Simple constructor.protectedAbstractConvexHullGenerator2D(boolean includeCollinearPoints, double tolerance) Simple constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Collection<Vector2D> findHullVertices(Collection<Vector2D> points) Find the convex hull vertices from the set of input points.generate(Collection<Vector2D> points) Builds the convex hull from the set of input points.doubleGet the tolerance below which points are considered identical.booleanReturns if collinear points on the hull will be added as hull vertices.
-
Field Details
-
DEFAULT_TOLERANCE
private static final double DEFAULT_TOLERANCEDefault value for tolerance.- See Also:
-
tolerance
private final double toleranceTolerance below which points are considered identical. -
includeCollinearPoints
private final boolean includeCollinearPointsIndicates if collinear points on the hull shall be present in the output. Iffalse, only the extreme points are added to the hull.
-
-
Constructor Details
-
AbstractConvexHullGenerator2D
protected AbstractConvexHullGenerator2D(boolean includeCollinearPoints) Simple constructor.The default tolerance (1e-10) will be used to determine identical points.
- Parameters:
includeCollinearPoints- indicates if collinear points on the hull shall be added as hull vertices
-
AbstractConvexHullGenerator2D
protected AbstractConvexHullGenerator2D(boolean includeCollinearPoints, double tolerance) Simple constructor.- Parameters:
includeCollinearPoints- indicates if collinear points on the hull shall be added as hull verticestolerance- tolerance below which points are considered identical
-
-
Method Details
-
getTolerance
public double getTolerance()Get the tolerance below which points are considered identical.- Returns:
- the tolerance below which points are considered identical
-
isIncludeCollinearPoints
public boolean isIncludeCollinearPoints()Returns if collinear points on the hull will be added as hull vertices.- Returns:
trueif collinear points are added as hull vertices, orfalseif only extreme points are present.
-
generate
public ConvexHull2D generate(Collection<Vector2D> points) throws NullArgumentException, ConvergenceException Builds the convex hull from the set of input points.- Specified by:
generatein interfaceConvexHullGenerator<Euclidean2D, Vector2D>- Specified by:
generatein interfaceConvexHullGenerator2D- Parameters:
points- the set of input points- Returns:
- the convex hull
- Throws:
NullArgumentException- if the input collection isnullConvergenceException- if generator fails to generate a convex hull for the given set of input points
-
findHullVertices
Find the convex hull vertices from the set of input points.- Parameters:
points- the set of input points- Returns:
- the convex hull vertices in CCW winding
-