Class Bounds3D
java.lang.Object
org.apache.commons.geometry.euclidean.AbstractBounds<Vector3D,Bounds3D>
org.apache.commons.geometry.euclidean.threed.Bounds3D
Class containing minimum and maximum points defining a 3D axis-aligned bounding box. Unless otherwise
noted, floating point comparisons used in this class are strict, meaning that values are considered equal
if and only if they match exactly.
Instances of this class are guaranteed to be immutable.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Bounds3D.Builder
builder()
Construct a newBounds3D.Builder
instance for creating bounds.boolean
Return true if the given point is strictly within or on the boundary of the bounding box.boolean
Return true if the given point is within or on the boundary of the bounding box, using the given precision context for floating point comparisons.boolean
static Bounds3D
Construct a new instance from the given points.static Bounds3D
Construct a new instance from the given points.int
hashCode()
boolean
hasSize
(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return true if the bounding box has non-zero size along each coordinate axis, as evaluated by the given precision context.intersection
(Bounds3D other) Return the intersection of this bounding box and the argument, or null if no intersection exists.boolean
intersects
(Bounds3D other) Return true if any point on the interior or boundary of this instance is also considered to be on the interior or boundary of the argument.toRegion
(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return a hyperplane-bounded region containing the same points as this instance.Methods inherited from class org.apache.commons.geometry.euclidean.AbstractBounds
eq, getCentroid, getDiagonal, getMax, getMin, toString
-
Constructor Details
-
Bounds3D
Simple constructor. Callers are responsible for ensuring the min is not greater than max.- Parameters:
min
- minimum pointmax
- maximum point
-
-
Method Details
-
hasSize
public boolean hasSize(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return true if the bounding box has non-zero size along each coordinate axis, as evaluated by the given precision context.- Specified by:
hasSize
in classAbstractBounds<Vector3D,
Bounds3D> - Parameters:
precision
- precision context used for floating point comparisons- Returns:
- true if the bounding box has non-zero size along each coordinate axis
-
contains
Return true if the given point is strictly within or on the boundary of the bounding box. In other words, true if returned ifpt >= mint
andpt <= maxt
for each coordinate valuet
. Floating point comparisons are strict; values are considered equal only if they match exactly.- Specified by:
contains
in classAbstractBounds<Vector3D,
Bounds3D> - Parameters:
pt
- the point to check- Returns:
- true if the given point is strictly within or on the boundary of the instance
- See Also:
-
contains
public boolean contains(Vector3D pt, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return true if the given point is within or on the boundary of the bounding box, using the given precision context for floating point comparisons. This is similar toAbstractBounds.contains(EuclideanVector)
but allows points that may be strictly outside of the box due to floating point errors to be considered inside.- Specified by:
contains
in classAbstractBounds<Vector3D,
Bounds3D> - Parameters:
pt
- the point to checkprecision
- precision context used to compare floating point values- Returns:
- if the given point is within or on the boundary of the bounds, as determined by the given precision context
- See Also:
-
intersects
Return true if any point on the interior or boundary of this instance is also considered to be on the interior or boundary of the argument. Specifically, true is returned ifaMint <= bMaxt
andaMaxt >= bMint
for all coordinate valuest
, wherea
is the current instance andb
is the argument. Floating point comparisons are strict; values are considered equal only if they match exactly.- Specified by:
intersects
in classAbstractBounds<Vector3D,
Bounds3D> - Parameters:
other
- bounding box to intersect with- Returns:
- true if the bounds intersect
-
intersection
Return the intersection of this bounding box and the argument, or null if no intersection exists. Floating point comparisons are strict; values are considered equal only if they match exactly. Note this this method may return bounding boxes with zero size in one or more coordinate axes.- Specified by:
intersection
in classAbstractBounds<Vector3D,
Bounds3D> - Parameters:
other
- bounding box to intersect with- Returns:
- the intersection of this instance and the argument, or null if no such intersection exists
- See Also:
-
toRegion
public Parallelepiped toRegion(org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Return a hyperplane-bounded region containing the same points as this instance.- Specified by:
toRegion
in classAbstractBounds<Vector3D,
Bounds3D> - Parameters:
precision
- precision context used for floating point comparisons in the returned region instance- Returns:
- a hyperplane-bounded region containing the same points as this instance
- Throws:
IllegalArgumentException
- if any dimension of the bounding box is zero as evaluated by the given precision context
-
hashCode
public int hashCode() -
equals
-
from
Construct a new instance from the given points.- Parameters:
first
- first pointmore
- additional points- Returns:
- a new instance containing the min and max coordinates values from the input points
-
from
Construct a new instance from the given points.- Parameters:
points
- input points- Returns:
- a new instance containing the min and max coordinates values from the input points
-
builder
Construct a newBounds3D.Builder
instance for creating bounds.- Returns:
- a new builder instance for creating bounds
-