Class Matrices.Hyperparallelepiped
- Enclosing class:
Matrices
Hyperparallelepiped: the simplest n-dimensional region.
In
More precisely, the region, specified by this class, consists of all such points
coordRanges[0].min()
≤ x0 ≤ coordRanges[0].max()
,
coordRanges[1].min()
≤ x1 ≤ coordRanges[1].max()
,
...,
coordRanges[n-1].min()
≤ xn−1 ≤ coordRanges[n-1].max()
,
where coordRanges is the result of Matrices.Region.coordRanges()
method.
Hyperparallelepipeds can be created by the following methods:
Matrices.Region.getHyperparallelepiped(IRange...)
,Matrices.Region.getSegment(IRange)
,Matrices.Region.getRectangle2D(IRange, IRange)
,Matrices.Region.getParallelepiped3D(IRange, IRange, IRange)
.
This class is immutable and thread-safe: there are no ways to modify settings of the created instance.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(long... coordinates) Returns true if and only if the point with the specified integer coordinates belongs to this region.boolean
isInsideMatrix
(Matrix<?> matrix) Returns true if and only if the coordinates of all points (with integer coordinates), belonging to this hyperparallelepiped, lies inside the specified matrix.boolean
isInsideMatrix
(Matrix<?> matrix, long... backShifts) Returns true if and only if the coordinates of all points (with integer coordinates), belonging to this hyperparallelepiped, will lie inside the specified matrix after subtraction the specified values backShifts from them.boolean
Returns true if this region is rectangular, that is if it contains the same set of integer points (points with integer coordinates) as somehyperparallelepiped
.sectionAtLastCoordinate
(long sectionCoordinateValue) Finds the intersection of this region with the hyperplane, described by the equation xn
−1=sectionCoordinateValue, and returns this intersection as an array of(n−1)-dimensional regions.toString()
Returns a brief string description of this object.Methods inherited from class net.algart.arrays.Matrices.Region
checkSectionAtLastCoordinate, coordRange, coordRanges, getConvexHyperpolyhedron, getHyperparallelepiped, getParallelepiped3D, getPolygon2D, getRectangle2D, getSegment, getSimplex, getTetrahedron3D, getTriangle2D, isContainsSupported, n
-
Method Details
-
isRectangular
public boolean isRectangular()Description copied from class:Matrices.Region
Returns true if this region is rectangular, that is if it contains the same set of integer points (points with integer coordinates) as somehyperparallelepiped
. This method always returns false if this region is not rectangular, but there is no guarantee that it returns true when it is rectangular.This default implementation returns false. In
Matrices.Hyperparallelepiped
class this method returns true. In all other inheritors of this class, implemented in this package, it returns false.- Overrides:
isRectangular
in classMatrices.Region
- Returns:
- true if this region is rectangular.
-
contains
public boolean contains(long... coordinates) Description copied from class:Matrices.Region
Returns true if and only if the point with the specified integer coordinates belongs to this region.The coordinates must contain at least
Matrices.Region.n()
elements. It can contain more thanMatrices.Region.n()
elements; then the extra elements will be ignored.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 ofMatrices.Region.isContainsSupported()
method before calling this one.However, this method must be correctly implemented, if this region is a
1-dimensional (Matrices.Region.n()
==1) andMatrices.Region.isRectangular()
method returns false.Note: even if the inheritor does not provide correct implementation of this method, it must always provide correct implementation of
Matrices.Region.sectionAtLastCoordinate(long)
method.- Specified by:
contains
in classMatrices.Region
- Parameters:
coordinates
- the coordinates of the point: the first element is x, the second is y, ...- Returns:
- true if and only if the point with the specified coordinates belongs to this region.
-
sectionAtLastCoordinate
Description copied from class:Matrices.Region
Finds the intersection of this region with the hyperplane, described by the equation xn
−1=sectionCoordinateValue, and returns this intersection as an array of(n−1)-dimensional regions. (Here xn
−1 is the last coordinate of the points:y-coordinate in2-dimensional case,z-coordinate in3-dimensional case, etc.) If the intersection is empty, this method returns an empty array ("new Region[0]"). This method never returns null.This method must not be used if this region is
1-dimensional (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
Matrices.Polygon2D
, 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.contains(long...)
method (Matrices.Region.isContainsSupported()
returns false). In this case, your implementation must not callMatrices.Region.contains(long...)
method orsuper. .Matrices.Region.sectionAtLastCoordinate(long)
- Overrides:
sectionAtLastCoordinate
in classMatrices.Region
- Parameters:
sectionCoordinateValue
- the value of the last coordinate.- Returns:
- the intersection of this region and the
(n−1)-dimensional hyperplane, corresponding to the specified value of the last coordinate (0, 1 or more regions, every region is(n−1)-dimensional ).
-
isInsideMatrix
Returns true if and only if the coordinates of all points (with integer coordinates), belonging to this hyperparallelepiped, lies inside the specified matrix.Note: the number of matrix dimensions can differ from the number of dimensions of this region. (All matrix dimensions after the first
Matrices.Region.n()
, as usual, are supposed to be 1.)More precisely, this method returns true if and only if the following 2*
Matrices.Region.n()
conditions are fulfilled:0 ≤ coordRanges[0].
min()
, coordRanges[0].max()
< matrix.dim
(0),
0 ≤ coordRanges[1].min()
, coordRanges[1].max()
< matrix.dim
(1),
...,
0 ≤ coordRanges[n-1].min()
, coordRanges[n-1].max()
< matrix.dim
(n-1)This method is equivalent to the following call:
isInsideMatrix
(matrix, new long[0]).- Parameters:
matrix
- the matrix.- Returns:
- true if this region lies fully inside the specified matrix.
- Throws:
NullPointerException
- if the matrix argument is null.
-
isInsideMatrix
Returns true if and only if the coordinates of all points (with integer coordinates), belonging to this hyperparallelepiped, will lie inside the specified matrix after subtraction the specified values backShifts from them.Note: the number of matrix dimensions can differ from the number of dimensions of this region. (All matrix dimensions after the first
Matrices.Region.n()
, as usual, are supposed to be 1.) The number of elements of backShifts also can differ from the number of dimensions. All missing elements of backShifts array are supposed to be zero.More precisely, this method returns true if and only if the following 2*
Matrices.Region.n()
conditions are fulfilled:0 ≤ coordRanges[0].
min()
- sh0,
coordRanges[0].max()
- sh0 < matrix.dim
(0),
0 ≤ coordRanges[1].min()
- sh1,
coordRanges[1].max()
- sh1 < matrix.dim
(1),
...,
0 ≤ coordRanges[n-1].min()
- shn-1,
coordRanges[n-1].max()
- shn-1 < matrix.dim
(n-1),where
shk = k < backShifts.length ? backShifts[k] : 0 - Parameters:
matrix
- the matrix.backShifts
- the shifts, which are subtracted from all coordinates of this region before the check.- Returns:
- true if this region, shifted backwards by the specified shifts, lies fully inside the specified matrix.
- Throws:
NullPointerException
- if the matrix or backShifts argument is null.
-
toString
Returns a brief string description of this object.The result of this method may depend on implementation.
-