public static final class Matrices.Polygon2D extends Matrices.Region
The points, lying precisely in the sides of the polygon (in particular, the vertices), belong to this region. Any degenerated cases are allowed: for example, vertices can be equal.
Polygon is specified by its vertices and can be created by the following method:
All calculations while building and processing polygons are performed in strictfp mode, so the results are absolutely identical on all platforms.
This class is immutable and thread-safe: there are no ways to modify settings of the created instance.
|Modifier and Type||Method and Description|
Returns true if and only if the point with the specified integer coordinates belongs to this region.
Indicates whether the method
Finds the intersection of this region with the hyperplane, described by the equation x
Returns a brief string description of this object.
Returns the coordinates of all vertices of the polygon.
checkSectionAtLastCoordinate, coordRange, coordRanges, getConvexHyperpolyhedron, getHyperparallelepiped, getParallelepiped3D, getPolygon2D, getRectangle2D, getSegment, getSimplex, getTetrahedron3D, getTriangle2D, isRectangular, n
public boolean contains(long... coordinates)
Warning! Some inheritors of this class does not provide correct implementation of this method.
In this case,
Matrices.Region.isContainsSupported() method returns false and this method throws
UnsupportedOperationException. So, you must always check the result of
Matrices.Region.isContainsSupported() method before calling this one.
Note: even if the inheritor does not provide correct implementation of this method,
it must always provide correct implementation of
public boolean isContainsSupported()
Matrices.Region.contains(long...)in this class works correctly. You should use
Matrices.Region.contains(long...)method only if this method returns true; in other case,
This default implementation returns true.
So, if you prefer not to implement
you must override this method and return false.
This method must return true if
Matrices.Region.n()==1 && !
public Matrices.Region sectionAtLastCoordinate(long sectionY)
n−1=sectionCoordinateValue, and returns this intersection as an array of
n−1 is the last coordinate of the points:
This method must not be used if this region is
Matrices.Region.n()==1). In this case, it throws IllegalStateException.
This default implementation is based on
Matrices.Region.contains(long...) method, which is supposed
to be correctly implemented.
Note: it is possible (in some rare exotic cases), that the regions, returned by this method,
intersects with each other: some points will belong to 2 and more elements of the result.
In particular, it is possible for
if some sides of the polygon lie exactly at the horizontal y=sectionCoordinateValue.
Implementations of this method in this packages, besides the implementation in
Matrices.Polygon2D class, never return more than 1 region in the result.
You must override this method if you prefer not to implement
Matrices.Region.isContainsSupported() returns false). In this case, your implementation
must not call
Matrices.Region.contains(long...) method or
sectionY- the value of the last coordinate.
public double vertices()
The returned array is a deep clone of the internal array stored in this object: no references, maintained by this object, are returned.
public java.lang.String toString()
The result of this method may depend on implementation.