public final class Bounds2D extends AbstractBounds<Vector2D,Bounds2D>
Instances of this class are guaranteed to be immutable.
Modifier and Type | Class and Description |
---|---|
static class |
Bounds2D.Builder
Class used to construct
Bounds2D instances. |
Modifier and Type | Method and Description |
---|---|
static Bounds2D.Builder |
builder()
Construct a new
Bounds2D.Builder instance for creating bounds. |
boolean |
contains(Vector2D pt)
Return true if the given point is strictly within or on the boundary of the bounding box.
|
boolean |
contains(Vector2D pt,
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.
|
boolean |
equals(Object obj) |
static Bounds2D |
from(Iterable<Vector2D> points)
Construct a new instance from the given points.
|
static Bounds2D |
from(Vector2D first,
Vector2D... more)
Construct a new instance from the given points.
|
int |
hashCode() |
boolean |
hasSize(Precision.DoubleEquivalence precision)
Return true if the bounding box has non-zero size along each coordinate axis, as
evaluated by the given precision context.
|
Bounds2D |
intersection(Bounds2D other)
Return the intersection of this bounding box and the argument, or null if no intersection exists.
|
boolean |
intersects(Bounds2D 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.
|
Parallelogram |
toRegion(Precision.DoubleEquivalence precision)
Return a hyperplane-bounded region containing the same points as this instance.
|
eq, getCentroid, getDiagonal, getMax, getMin, toString
public boolean hasSize(Precision.DoubleEquivalence precision)
hasSize
in class AbstractBounds<Vector2D,Bounds2D>
precision
- precision context used for floating point comparisonspublic boolean contains(Vector2D pt)
pt >= mint
and
pt <= maxt
for each coordinate value t
.
Floating point comparisons are strict; values are considered equal only if they match exactly.contains
in class AbstractBounds<Vector2D,Bounds2D>
pt
- the point to checkAbstractBounds.contains(EuclideanVector, Precision.DoubleEquivalence)
public boolean contains(Vector2D pt, Precision.DoubleEquivalence precision)
AbstractBounds.contains(EuclideanVector)
but allows points that may be strictly outside of the box due to floating point errors to be considered
inside.contains
in class AbstractBounds<Vector2D,Bounds2D>
pt
- the point to checkprecision
- precision context used to compare floating point valuesAbstractBounds.contains(EuclideanVector, Precision.DoubleEquivalence)
public boolean intersects(Bounds2D other)
aMint <= bMaxt
and aMaxt >= bMint
for all coordinate values t
, where a
is the current instance and b
is the argument.
Floating point comparisons are strict; values are considered equal only if they match exactly.intersects
in class AbstractBounds<Vector2D,Bounds2D>
other
- bounding box to intersect withpublic Bounds2D intersection(Bounds2D other)
intersection
in class AbstractBounds<Vector2D,Bounds2D>
other
- bounding box to intersect withAbstractBounds.intersects(AbstractBounds)
public Parallelogram toRegion(Precision.DoubleEquivalence precision)
toRegion
in class AbstractBounds<Vector2D,Bounds2D>
precision
- precision context used for floating point comparisons in the returned
region instanceIllegalArgumentException
- if any dimension of the bounding box is zero
as evaluated by the given precision contextpublic static Bounds2D from(Vector2D first, Vector2D... more)
first
- first pointmore
- additional pointspublic static Bounds2D from(Iterable<Vector2D> points)
points
- input pointspublic static Bounds2D.Builder builder()
Bounds2D.Builder
instance for creating bounds.Copyright © 2016–2021 The Apache Software Foundation. All rights reserved.