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

public Class ConvexHull2D

extends Object
implements ConvexHull<Euclidean2D, Vector2D>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.math3.geometry.hull.ConvexHull
Imports
java.io.Serializable, org.apache.commons.math3.exception.InsufficientDataException, .MathIllegalArgumentException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.geometry.euclidean.twod.Euclidean2D, .Line, .Segment, .Vector2D, org.apache.commons.math3.geometry.hull.ConvexHull, org.apache.commons.math3.geometry.partitioning.Region, .RegionFactory, org.apache.commons.math3.util.MathArrays, .Precision

This class represents a convex hull in an two-dimensional euclidean space.
Since
3.3

Field Summary

Modifier and TypeField and Description
private transient Segment[]
lineSegments

Line segments of the hull.

private static final long
serialVersionUID

Serializable UID.

private final double
tolerance

Tolerance threshold used during creation of the hull vertices.

private final Vector2D[]
vertices

Vertices of the hull.

Constructor Summary

AccessConstructor and Description
public
ConvexHull2D(final Vector2D[]
the vertices of the convex hull, must be ordered
vertices
,
final double
tolerance below which points are considered identical
tolerance
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public Region<Euclidean2D>
createRegion()

Implements org.apache.commons.math3.geometry.hull.ConvexHull.createRegion.

Returns a new region that is enclosed by the convex hull.

public Segment[]

Returns:

the line segments of the convex hull
getLineSegments
()

Get the line segments of the convex hull, ordered.

public Vector2D[]
getVertices()

Implements org.apache.commons.math3.geometry.hull.ConvexHull.getVertices.

Get the vertices of the convex hull.

private boolean

Returns:

true if the vertices form a convex hull, false otherwise
isConvex
(final Vector2D[]
the hull vertices
hullVertices
)

Checks whether the given hull vertices form a convex hull.

private Segment[]

Returns:

the array of line segments
retrieveLineSegments
()

Retrieve the line segments from the cached array or create them if needed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lineSegmentsback to summary
private transient Segment[] lineSegments

Line segments of the hull. The array is not serialized and will be created from the vertices on first access.

serialVersionUIDback to summary
private static final long serialVersionUID

Serializable UID.

toleranceback to summary
private final double tolerance

Tolerance threshold used during creation of the hull vertices.

verticesback to summary
private final Vector2D[] vertices

Vertices of the hull.

Constructor Detail

ConvexHull2Dback to summary
public ConvexHull2D(final Vector2D[] vertices, final double tolerance) throws MathIllegalArgumentException

Simple constructor.

Parameters
vertices:Vector2D[]

the vertices of the convex hull, must be ordered

tolerance:double

tolerance below which points are considered identical

Exceptions
MathIllegalArgumentException:
if the vertices do not form a convex hull

Method Detail

createRegionback to summary
public Region<Euclidean2D> createRegion() throws InsufficientDataException

Implements org.apache.commons.math3.geometry.hull.ConvexHull.createRegion.

Doc from org.apache.commons.math3.geometry.hull.ConvexHull.createRegion.

Returns a new region that is enclosed by the convex hull.

Returns:Region<Euclidean2D>

the region enclosed by the convex hull

Exceptions
InsufficientDataException:
if the number of vertices is not enough to build a region in the respective space
getLineSegmentsback to summary
public Segment[] getLineSegments()

Get the line segments of the convex hull, ordered.

Returns:Segment[]

the line segments of the convex hull

getVerticesback to summary
public Vector2D[] getVertices()

Implements org.apache.commons.math3.geometry.hull.ConvexHull.getVertices.

Doc from org.apache.commons.math3.geometry.hull.ConvexHull.getVertices.

Get the vertices of the convex hull.

Returns:Vector2D[]

vertices of the convex hull

isConvexback to summary
private boolean isConvex(final Vector2D[] hullVertices)

Checks whether the given hull vertices form a convex hull.

Parameters
hullVertices:Vector2D[]

the hull vertices

Returns:boolean

true if the vertices form a convex hull, false otherwise

retrieveLineSegmentsback to summary
private Segment[] retrieveLineSegments()

Retrieve the line segments from the cached array or create them if needed.

Returns:Segment[]

the array of line segments