math.geom2d.polygon
Class MultiPolygon2D
- java.lang.Object
-
- math.geom2d.polygon.MultiPolygon2D
-
- All Implemented Interfaces:
- CirculinearDomain2D, CirculinearShape2D, Domain2D, GeometricObject2D, Polygon2D, Shape2D
public class MultiPolygon2D extends java.lang.Object implements Domain2D, Polygon2D
A polygonal domain whose boundary is composed of several disjoint continuous LinearRing2D.
-
-
Constructor Summary
Constructors Constructor and Description MultiPolygon2D()MultiPolygon2D(java.util.Collection<LinearRing2D> lines)MultiPolygon2D(int nRings)Ensures the inner buffer has enough capacity for storing the required number of rings.MultiPolygon2D(LinearRing2D... rings)MultiPolygon2D(Polygon2D polygon)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidaddRing(LinearRing2D ring)voidaddVertex(Point2D position)Adds a vertex at the end of the last ring of this polygon.booleanalmostEquals(GeometricObject2D obj, double eps)Checks if the two objects are similar up to a given threshold value.doublearea()Computes the signed area of the polygon.Polygon2DasPolygon(int n)Returns an approximation of the domain as a polygon, or a MultiPolygon.CirculinearContourArray2D<LinearRing2D>boundary()Returns the boundary of the set.Box2DboundingBox()Returns the bounding box of the shape.CirculinearDomain2Dbuffer(double dist)Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d.Point2Dcentroid()Computes the centroid (center of mass) of the polygon.voidclearRings()Polygon2Dclip(Box2D box)Clips the polygon with the specified box.MultiPolygon2Dclone()Deprecated.use copy constructor instead (0.11.2)intclosestVertexIndex(Point2D point)Computes the index of the closest vertex to the input point.Polygon2Dcomplement()Returns the domain which complements this domain in the plane.booleancontains(double x, double y)Checks if the shape contains the planar point defined by (x,y).booleancontains(Point2D point)Checks if the shape contains the given point.java.util.Collection<LinearRing2D>contours()Returns the set of contours that enclose this domain.static MultiPolygon2Dcreate(java.util.Collection<LinearRing2D> rings)static MultiPolygon2Dcreate(LinearRing2D... rings)doubledistance(double x, double y)Returns the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e.doubledistance(Point2D p)Returns the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.voiddraw(java.awt.Graphics2D g2)Draws the boundary of the domain, using current Stroke and color.intedgeNumber()Returns the number of edges of the polygonjava.util.Collection<LineSegment2D>edges()Return the edges as line segments of the polygonbooleanequals(java.lang.Object obj)voidfill(java.awt.Graphics2D g)Fills the interior of the domain, using the Graphics current Paint.LinearRing2DgetRing(int index)voidinsertRing(int index, LinearRing2D ring)voidinsertVertex(int index, Point2D point)Inserts a vertex at the given positionbooleanisBounded()Returns true if the shape is bounded, that is if we can draw a finite rectangle enclosing the shape.booleanisEmpty()The MultiPolygon2D is empty either if it contains no ring, or if all rings are empty.voidremoveRing(LinearRing2D ring)voidremoveVertex(int i)Returns the i-th vertex of the polygon.intringNumber()voidsetRing(int index, LinearRing2D ring)voidsetVertex(int i, Point2D point)Sets the position of the i-th vertex of this polygon.MultiPolygon2Dtransform(AffineTransform2D trans)Transforms the shape by an affine transform.CirculinearDomain2Dtransform(CircleInversion2D inv)Transforms the shape by a circle inversion.Point2Dvertex(int i)Returns the i-th vertex of the polygon.intvertexNumber()Returns the total number of vertices in this polygon.java.util.Collection<Point2D>vertices()Returns the vertices (singular points) of the polygon
-
-
-
Constructor Detail
-
MultiPolygon2D
public MultiPolygon2D()
-
MultiPolygon2D
public MultiPolygon2D(int nRings)
Ensures the inner buffer has enough capacity for storing the required number of rings.
-
MultiPolygon2D
public MultiPolygon2D(LinearRing2D... rings)
-
MultiPolygon2D
public MultiPolygon2D(Polygon2D polygon)
-
MultiPolygon2D
public MultiPolygon2D(java.util.Collection<LinearRing2D> lines)
-
-
Method Detail
-
create
public static MultiPolygon2D create(java.util.Collection<LinearRing2D> rings)
-
create
public static MultiPolygon2D create(LinearRing2D... rings)
-
addRing
public void addRing(LinearRing2D ring)
-
insertRing
public void insertRing(int index, LinearRing2D ring)
-
removeRing
public void removeRing(LinearRing2D ring)
-
clearRings
public void clearRings()
-
getRing
public LinearRing2D getRing(int index)
-
setRing
public void setRing(int index, LinearRing2D ring)
-
ringNumber
public int ringNumber()
-
area
public double area()
Computes the signed area of the polygon.
-
centroid
public Point2D centroid()
Computes the centroid (center of mass) of the polygon.
-
edges
public java.util.Collection<LineSegment2D> edges()
Description copied from interface:Polygon2DReturn the edges as line segments of the polygon
-
edgeNumber
public int edgeNumber()
Description copied from interface:Polygon2DReturns the number of edges of the polygon- Specified by:
edgeNumberin interfacePolygon2D
-
vertices
public java.util.Collection<Point2D> vertices()
Description copied from interface:Polygon2DReturns the vertices (singular points) of the polygon
-
vertex
public Point2D vertex(int i)
Returns the i-th vertex of the polygon.
-
setVertex
public void setVertex(int i, Point2D point)Sets the position of the i-th vertex of this polygon.
-
addVertex
public void addVertex(Point2D position)
Adds a vertex at the end of the last ring of this polygon.
-
insertVertex
public void insertVertex(int index, Point2D point)Inserts a vertex at the given position- Specified by:
insertVertexin interfacePolygon2D- Parameters:
index- index at which the specified vertex is to be insertedpoint- the position of the new vertex- Throws:
java.lang.RuntimeException- if this polygon has no ringjava.lang.IllegalArgumentException- if index is not smaller than vertex number
-
removeVertex
public void removeVertex(int i)
Returns the i-th vertex of the polygon.- Specified by:
removeVertexin interfacePolygon2D- Parameters:
i- index of the vertex, between 0 and the number of vertices minus one
-
vertexNumber
public int vertexNumber()
Returns the total number of vertices in this polygon. The total number is computed as the sum of vertex number in each ring of the polygon.- Specified by:
vertexNumberin interfacePolygon2D
-
closestVertexIndex
public int closestVertexIndex(Point2D point)
Computes the index of the closest vertex to the input point.- Specified by:
closestVertexIndexin interfacePolygon2D
-
transform
public CirculinearDomain2D transform(CircleInversion2D inv)
Description copied from interface:CirculinearShape2DTransforms the shape by a circle inversion. The result is still an instance a CirculinearShape2D.- Specified by:
transformin interfaceCirculinearDomain2D- Specified by:
transformin interfaceCirculinearShape2D- Parameters:
inv- the circle inversion- Returns:
- the transformed shape
-
buffer
public CirculinearDomain2D buffer(double dist)
Description copied from interface:CirculinearShape2DComputes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d.- Specified by:
bufferin interfaceCirculinearShape2D- Parameters:
dist- the maximal distance between a point of the buffer and the shape- Returns:
- the buffer of the shape
-
asPolygon
public Polygon2D asPolygon(int n)
Description copied from interface:Domain2DReturns an approximation of the domain as a polygon, or a MultiPolygon.
-
boundary
public CirculinearContourArray2D<LinearRing2D> boundary()
Description copied from interface:Domain2DReturns the boundary of the set. This boundary is either a continuous non intersecting curve (connected domain), or a set of non intersecting continuous curve (one continuous non-intersection for each connected part of the domain).The returned curve is oriented, with an interior and an exterior.
-
contours
public java.util.Collection<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.
-
complement
public Polygon2D complement()
Description copied from interface:Domain2DReturns the domain which complements this domain in the plane.- Specified by:
complementin interfaceCirculinearDomain2D- Specified by:
complementin interfaceDomain2D- Specified by:
complementin interfacePolygon2D- Returns:
- the complement of this domain.
-
boundingBox
public Box2D boundingBox()
Description copied from interface:Shape2DReturns the bounding box of the shape.- Specified by:
boundingBoxin interfaceShape2D- Returns:
- the bounding box of the shape.
-
distance
public double distance(Point2D p)
Description copied from interface:Shape2DReturns the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.
-
distance
public double distance(double x, double y)Description copied from interface:Shape2DReturns the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e. fillable) shape.
-
isBounded
public boolean isBounded()
Description copied from interface:Shape2DReturns true if the shape is bounded, that is if we can draw a finite rectangle enclosing the shape. For example, a straight line or a parabola are not bounded.
-
isEmpty
public boolean isEmpty()
The MultiPolygon2D is empty either if it contains no ring, or if all rings are empty.
-
transform
public MultiPolygon2D transform(AffineTransform2D trans)
Description copied from interface:Shape2DTransforms the shape by an affine transform. Subclasses may override the type of returned shape.
-
contains
public boolean contains(Point2D point)
Description copied from interface:Shape2DChecks if the shape contains the given point.
-
contains
public boolean contains(double x, double y)Description copied from interface:Shape2DChecks if the shape contains the planar point defined by (x,y).
-
draw
public void draw(java.awt.Graphics2D g2)
Description copied from interface:Domain2DDraws the boundary of the domain, using current Stroke and color.
-
fill
public void fill(java.awt.Graphics2D g)
Description copied from interface:Domain2DFills the interior of the domain, using the Graphics current Paint.
-
almostEquals
public boolean almostEquals(GeometricObject2D obj, double eps)
Description copied from interface:GeometricObject2DChecks if the two objects are similar up to a given threshold value. This method can be used to compare the results of geometric computations, that introduce errors due to numerical computations.- Specified by:
almostEqualsin interfaceGeometricObject2D- Parameters:
obj- the object to compareeps- a threshold value, for example the minimal coordinate difference- Returns:
- true if both object have the same value up to the threshold
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
clone
@Deprecated public MultiPolygon2D clone()
Deprecated. use copy constructor instead (0.11.2)- Overrides:
clonein classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG