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 double
Default value for tolerance.private final boolean
Indicates if collinear points on the hull shall be present in the output.private final double
Tolerance below which points are considered identical. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractConvexHullGenerator2D
(boolean includeCollinearPoints) Simple constructor.protected
AbstractConvexHullGenerator2D
(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.double
Get the tolerance below which points are considered identical.boolean
Returns 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:
true
if collinear points are added as hull vertices, orfalse
if 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:
generate
in interfaceConvexHullGenerator<Euclidean2D,
Vector2D> - Specified by:
generate
in interfaceConvexHullGenerator2D
- Parameters:
points
- the set of input points- Returns:
- the convex hull
- Throws:
NullArgumentException
- if the input collection isnull
ConvergenceException
- 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
-