Package arc.math.geom
Class BoundingBox
java.lang.Object
arc.math.geom.BoundingBox
Encapsulates an axis aligned bounding box represented by a minimum and a maximum Vector. Additionally you can query for the
bounding box's center, dimensions and corner points.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstructs a new bounding box with the minimum and maximum vector set to zeros.BoundingBox
(BoundingBox bounds) Constructs a new bounding box from the given bounding box.BoundingBox
(Vec3 minimum, Vec3 maximum) Constructs the new bounding box using the given minimum and maximum vector. -
Method Summary
Modifier and TypeMethodDescriptionclr()
Sets the minimum and maximum vector to zeros.boolean
Returns whether the given bounding box is contained in this bounding box.boolean
Returns whether the given vector is contained in this bounding box.ext
(float x, float y, float z) Extends the bounding box by the given vector.ext
(BoundingBox a_bounds) Extends this bounding box by the given bounding box.Extends the bounding box to incorporate the givenVec3
.Extends this bounding box by the given sphere.float
float
float
getCorner000
(Vec3 out) getCorner001
(Vec3 out) getCorner010
(Vec3 out) getCorner011
(Vec3 out) getCorner100
(Vec3 out) getCorner101
(Vec3 out) getCorner110
(Vec3 out) getCorner111
(Vec3 out) float
getDepth()
getDimensions
(Vec3 out) float
float
getWidth()
inf()
Sets the minimum and maximum vector to positive and negative infinity.boolean
Returns whether the given bounding box is intersecting this bounding box (at least one point in).boolean
isValid()
Returns whether this bounding box is valid.set
(BoundingBox bounds) Sets the given bounding box.Sets the bounding box minimum and maximum vector from the given points.Sets the given minimum and maximum vector.Sets the bounding box minimum and maximum vector from the given points.toString()
-
Field Details
-
min
-
max
-
-
Constructor Details
-
BoundingBox
public BoundingBox()Constructs a new bounding box with the minimum and maximum vector set to zeros. -
BoundingBox
Constructs a new bounding box from the given bounding box.- Parameters:
bounds
- The bounding box to copy
-
BoundingBox
Constructs the new bounding box using the given minimum and maximum vector.- Parameters:
minimum
- The minimum vectormaximum
- The maximum vector
-
-
Method Details
-
getCenter
- Parameters:
out
- TheVec3
to receive the center of the bounding box.- Returns:
- The vector specified with the out argument.
-
getCenterX
public float getCenterX() -
getCenterY
public float getCenterY() -
getCenterZ
public float getCenterZ() -
getCorner000
-
getCorner001
-
getCorner010
-
getCorner011
-
getCorner100
-
getCorner101
-
getCorner110
-
getCorner111
-
getDimensions
- Parameters:
out
- TheVec3
to receive the dimensions of this bounding box on all three axis.- Returns:
- The vector specified with the out argument
-
getWidth
public float getWidth() -
getHeight
public float getHeight() -
getDepth
public float getDepth() -
getMin
- Parameters:
out
- TheVec3
to receive the minimum values.- Returns:
- The vector specified with the out argument
-
getMax
- Parameters:
out
- TheVec3
to receive the maximum values.- Returns:
- The vector specified with the out argument
-
set
Sets the given bounding box.- Parameters:
bounds
- The bounds.- Returns:
- This bounding box for chaining.
-
set
Sets the given minimum and maximum vector.- Parameters:
minimum
- The minimum vectormaximum
- The maximum vector- Returns:
- This bounding box for chaining.
-
set
Sets the bounding box minimum and maximum vector from the given points.- Parameters:
points
- The points.- Returns:
- This bounding box for chaining.
-
set
Sets the bounding box minimum and maximum vector from the given points.- Parameters:
points
- The points.- Returns:
- This bounding box for chaining.
-
inf
Sets the minimum and maximum vector to positive and negative infinity.- Returns:
- This bounding box for chaining.
-
ext
Extends the bounding box to incorporate the givenVec3
.- Parameters:
point
- The vector- Returns:
- This bounding box for chaining.
-
clr
Sets the minimum and maximum vector to zeros.- Returns:
- This bounding box for chaining.
-
isValid
public boolean isValid()- Returns:
- True in case the bounding box is valid, false otherwise
-
ext
Extends this bounding box by the given bounding box.- Parameters:
a_bounds
- The bounding box- Returns:
- This bounding box for chaining.
-
ext
Extends this bounding box by the given sphere.- Parameters:
center
- Sphere centerradius
- Sphere radius- Returns:
- This bounding box for chaining.
-
contains
Returns whether the given bounding box is contained in this bounding box.- Parameters:
b
- The bounding box- Returns:
- Whether the given bounding box is contained
-
intersects
Returns whether the given bounding box is intersecting this bounding box (at least one point in).- Parameters:
b
- The bounding box- Returns:
- Whether the given bounding box is intersected
-
contains
Returns whether the given vector is contained in this bounding box.- Parameters:
v
- The vector- Returns:
- Whether the vector is contained or not.
-
toString
-
ext
Extends the bounding box by the given vector.- Parameters:
x
- The x-coordinatey
- The y-coordinatez
- The z-coordinate- Returns:
- This bounding box for chaining.
-