public class MonotoneChain extends Object
The runtime complexity is O(n log n), with n being the number of input points. If the point set is already sorted (by x-coordinate), the runtime complexity is O(n).
The implementation is not sensitive to collinear points on the hull. The parameter
includeCollinearPoints allows to control the behavior with regard to collinear points.
If true, all points on the boundary of the hull will be added to the hull vertices,
otherwise only the extreme points will be present. By default, collinear points are not added
as hull vertices.
| Constructor and Description |
|---|
MonotoneChain(boolean includeCollinearPoints,
DoublePrecisionContext precision)
Create a new instance with the given parameters.
|
MonotoneChain(DoublePrecisionContext precision)
Create a new instance that only includes extreme points as hull vertices.
|
| Modifier and Type | Method and Description |
|---|---|
Collection<Vector2D> |
findHullVertices(Collection<Vector2D> points)
Find the convex hull vertices from the set of input points.
|
ConvexHull2D |
generate(Collection<Vector2D> points)
Build a convex hull from the set of input points.
|
DoublePrecisionContext |
getPrecision()
Get the object used to determine floating point equality for this region.
|
boolean |
isIncludeCollinearPoints()
Returns if collinear points on the hull will be added as hull vertices.
|
public MonotoneChain(DoublePrecisionContext precision)
precision - precision context used to compare floating point numberspublic MonotoneChain(boolean includeCollinearPoints,
DoublePrecisionContext precision)
includeCollinearPoints - whether collinear points shall be added as hull verticesprecision - precision context used to compare floating point numberspublic Collection<Vector2D> findHullVertices(Collection<Vector2D> points)
points - the set of input pointspublic DoublePrecisionContext getPrecision()
public boolean isIncludeCollinearPoints()
true if collinear points are added as hull vertices, or false
if only extreme points are present.public ConvexHull2D generate(Collection<Vector2D> points)
generate in interface ConvexHullGenerator<Vector2D>generate in interface ConvexHullGenerator2Dpoints - the set of input pointsCopyright © 2016–2020 The Apache Software Foundation. All rights reserved.