math.geom2d.polygon
Interface Polygon2D
-
- All Superinterfaces:
- CirculinearDomain2D, CirculinearShape2D, Domain2D, GeometricObject2D, Shape2D
- All Known Implementing Classes:
- HRectangle2D, MultiPolygon2D, Rectangle2D, SimplePolygon2D
public interface Polygon2D extends CirculinearDomain2D
Represent any class made of a finite set of simply connected edges. This include simple polygons, multiple polygons, or more specialized shapes like rectangles, squares... The boundary of a polygon is a collection of LinearRing2D.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description voidaddVertex(Point2D point)Adds a vertex as last vertex of this polygon.doublearea()Returns the signed area of the polygon.CirculinearContourArray2D<? extends LinearRing2D>boundary()Overrides the definition of boundary() such that the boundary of a polygon is defined as a set of LinearRing2D.Point2Dcentroid()Returns the centroid (center of mass) of the polygon.Polygon2Dclip(Box2D box)Clip the shape with the given box, and returns a new shape.intclosestVertexIndex(Point2D point)Returns the index of the closest vertex to the input point.Polygon2Dcomplement()Returns the complementary polygon.java.util.Collection<? extends LinearRing2D>contours()Returns the set of contours that enclose this domain.intedgeNumber()Returns the number of edges of the polygonjava.util.Collection<? extends LineSegment2D>edges()Return the edges as line segments of the polygonvoidinsertVertex(int index, Point2D point)Inserts a vertex at the specified position.voidremoveVertex(int index)Removes the vertex at the given index.voidsetVertex(int i, Point2D point)Sets the position of the i-th vertexPolygon2Dtransform(AffineTransform2D trans)Returns the new Polygon created by an affine transform of this polygon.Point2Dvertex(int i)Returns the i-th vertex of the polygon.intvertexNumber()Returns the number of vertices of the polygonjava.util.Collection<Point2D>vertices()Returns the vertices (singular points) of the polygon-
Methods inherited from interface math.geom2d.circulinear.CirculinearDomain2D
transform
-
Methods inherited from interface math.geom2d.circulinear.CirculinearShape2D
buffer
-
Methods inherited from interface math.geom2d.Shape2D
boundingBox, contains, contains, distance, distance, isBounded, isEmpty
-
Methods inherited from interface math.geom2d.GeometricObject2D
almostEquals
-
-
-
-
Method Detail
-
vertices
java.util.Collection<Point2D> vertices()
Returns the vertices (singular points) of the polygon
-
vertex
Point2D vertex(int i)
Returns the i-th vertex of the polygon.- Parameters:
i- index of the vertex, between 0 and the number of vertices
-
setVertex
void setVertex(int i, Point2D point)Sets the position of the i-th vertex- Parameters:
i- the vertex indexpoint- the new position of the vertex- Throws:
java.lang.UnsupportedOperationException- if this polygon implementation does not support vertex modification
-
addVertex
void addVertex(Point2D point)
Adds a vertex as last vertex of this polygon.- Parameters:
point- the position of the new vertex- Throws:
java.lang.UnsupportedOperationException- if this polygon implementation does not support vertex modification
-
insertVertex
void insertVertex(int index, Point2D point)Inserts a vertex at the specified position.- Parameters:
index- index at which the specified vertex is to be insertedpoint- the position of the new vertex- Throws:
java.lang.UnsupportedOperationException- if this polygon implementation does not support vertex modification
-
removeVertex
void removeVertex(int index)
Removes the vertex at the given index.- Parameters:
index- index of the vertex to remove- Throws:
java.lang.UnsupportedOperationException- if this polygon implementation does not support vertex modification
-
vertexNumber
int vertexNumber()
Returns the number of vertices of the polygon- Since:
- 0.6.3
-
closestVertexIndex
int closestVertexIndex(Point2D point)
Returns the index of the closest vertex to the input point.
-
edges
java.util.Collection<? extends LineSegment2D> edges()
Return the edges as line segments of the polygon
-
edgeNumber
int edgeNumber()
Returns the number of edges of the polygon
-
centroid
Point2D centroid()
Returns the centroid (center of mass) of the polygon.
-
area
double area()
Returns the signed area of the polygon.
-
boundary
CirculinearContourArray2D<? extends LinearRing2D> boundary()
Overrides the definition of boundary() such that the boundary of a polygon is defined as a set of LinearRing2D.- Specified by:
boundaryin interfaceCirculinearDomain2D- Specified by:
boundaryin interfaceDomain2D- Returns:
- the boundary of the domain
-
contours
java.util.Collection<? extends LinearRing2D> contours()
Description copied from interface:Domain2DReturns the set of contours that enclose this domain. The result is a collection of shapes that implement the Contour2D interface.- Specified by:
contoursin interfaceCirculinearDomain2D- Specified by:
contoursin interfaceDomain2D- See Also:
Contour2D
-
complement
Polygon2D complement()
Returns the complementary polygon.- Specified by:
complementin interfaceCirculinearDomain2D- Specified by:
complementin interfaceDomain2D- Returns:
- the polygon complementary to this
-
transform
Polygon2D transform(AffineTransform2D trans)
Returns the new Polygon created by an affine transform of this polygon.
-
-
DMelt 3.0 © DataMelt by jWork.ORG