Package org.tinfour.voronoi
Class ThiessenPolygon
- java.lang.Object
-
- org.tinfour.voronoi.ThiessenPolygon
-
public class ThiessenPolygon extends Object
Provides elements and methods for representing a Thiessen Polygon created by the BoundedVoronoi class.
-
-
Constructor Summary
Constructors Constructor Description ThiessenPolygon(Vertex vertex, List<IQuadEdge> edgeList, boolean open)Constructs a Thiessen Polygon representation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetArea()Gets the area of the Voronoi polygon.Rectangle2DgetBounds()Gets the bounds of the polygonList<IQuadEdge>getEdges()Gets the edges that comprise the polygonintgetIndex()Gets the index element of the defining vertex for this polygon.VertexgetVertex()Gets the defining vertex of the polygon.booleanisOpen()Indicates that in a true Voronoi Diagram the polygon would not form a closed polygon and would have an infinite domain.booleanisPointInPolygon(double x, double y)Indicates whether the specified coordinate point lies inside or on an edge of the polygon associated with this instance.StringtoString()
-
-
-
Constructor Detail
-
ThiessenPolygon
public ThiessenPolygon(Vertex vertex, List<IQuadEdge> edgeList, boolean open)
Constructs a Thiessen Polygon representation. The open flag is used to indicate polygons of an infinite area that extend beyomd the bounds of the Delaunay Triangulation associated with the Voronoi Diagram- Parameters:
vertex- The vertex at the center of the polygonedgeList- a list of the edges comprising the polygonopen- indicates whether the polygon is infinite (open) finite (closed).
-
-
Method Detail
-
getEdges
public List<IQuadEdge> getEdges()
Gets the edges that comprise the polygon- Returns:
- a valid array of edges
-
getArea
public double getArea()
Gets the area of the Voronoi polygon. If the polygon is an open polygon, its actual area would be infinite, but the reported area matches the domain of the Bounded Voronoi Diagram class.- Returns:
- a valid, finite floating point value
-
getVertex
public Vertex getVertex()
Gets the defining vertex of the polygon.- Returns:
- the vertex
-
getBounds
public Rectangle2D getBounds()
Gets the bounds of the polygon- Returns:
- a safe copy of a rectangle instance.
-
isPointInPolygon
public boolean isPointInPolygon(double x, double y)Indicates whether the specified coordinate point lies inside or on an edge of the polygon associated with this instance.- Parameters:
x- the Cartesian x coordinate of the query pointy- the Cartesian y coordinate of the query point- Returns:
- true if the point is inside the polygon; otherwise, false
-
isOpen
public boolean isOpen()
Indicates that in a true Voronoi Diagram the polygon would not form a closed polygon and would have an infinite domain.- Returns:
- true if the polygon is open, otherwise false.
-
getIndex
public int getIndex()
Gets the index element of the defining vertex for this polygon. The vertex index is under the control of the calling application and is not modified by the Voronoi classes. Note that the index of a vertex is not necessarily unique but left to the requirements of the application that constructs it.- Returns:
- an integer value
-
-