APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.math.collision

public Class BoundingBox

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, java.util.List, com.badlogic.gdx.math.Matrix4, .Vector3

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.
Author
[email protected], Xoppa

Field Summary

Modifier and TypeField and Description
private final Vector3
private final Vector3
public final Vector3
max

Maximum vector.

public final Vector3
min

Minimum vector.

private static final long
private static final Vector3

Constructor Summary

AccessConstructor and Description
public
BoundingBox()

Constructs a new bounding box with the minimum and maximum vector set to zeros.

public
BoundingBox(BoundingBox
The bounding box to copy
bounds
)

Constructs a new bounding box from the given bounding box.

public
BoundingBox(Vector3
The minimum vector
minimum
,
Vector3
The maximum vector
maximum
)

Constructs the new bounding box using the given minimum and maximum vector.

Method Summary

Modifier and TypeMethod and Description
public BoundingBox

Returns:

This bounding box for chaining.
clr
()

Sets the minimum and maximum vector to zeros.

public boolean

Returns:

Whether the given bounding box is contained
contains
(BoundingBox
The bounding box
b
)

Returns whether the given bounding box is contained in this bounding box.

public boolean

Returns:

Whether the given oriented bounding box is contained
contains
(OrientedBoundingBox
The bounding box
obb
)

Returns whether the given oriented bounding box is contained in this oriented bounding box.

public boolean

Returns:

Whether the vector is contained or not.
contains
(Vector3
The vector
v
)

Returns whether the given vector is contained in this bounding box.

public BoundingBox

Returns:

This bounding box for chaining.
ext
(Vector3
The vector
point
)

Extends the bounding box to incorporate the given Vector3.

public BoundingBox

Returns:

This bounding box for chaining.
ext
(BoundingBox
The bounding box
a_bounds
)

Extends this bounding box by the given bounding box.

public BoundingBox

Returns:

This bounding box for chaining.
ext
(Vector3
Sphere center
center
,
float
Sphere radius
radius
)

Extends this bounding box by the given sphere.

public BoundingBox

Returns:

This bounding box for chaining.
ext
(BoundingBox
The bounding box
bounds
,
Matrix4
The transformation matrix to apply to bounds, before using it to extend this bounding box.
transform
)

Extends this bounding box by the given transformed bounding box.

public BoundingBox

Returns:

This bounding box for chaining.
ext
(float
The x-coordinate
x
,
float
The y-coordinate
y
,
float
The z-coordinate
z
)

Extends the bounding box by the given vector.

public Vector3
getCenter(Vector3
The Vector3 to receive the center of the bounding box.
out
)

Returns: The vector specified with the out argument.

public float
public float
public float
public Vector3
getCorner000(final Vector3 out)

public Vector3
getCorner001(final Vector3 out)

public Vector3
getCorner010(final Vector3 out)

public Vector3
getCorner011(final Vector3 out)

public Vector3
getCorner100(final Vector3 out)

public Vector3
getCorner101(final Vector3 out)

public Vector3
getCorner110(final Vector3 out)

public Vector3
getCorner111(final Vector3 out)

public float
public Vector3
getDimensions(final Vector3
The Vector3 to receive the dimensions of this bounding box on all three axis.
out
)

Returns: The vector specified with the out argument

public float
public Vector3
getMax(final Vector3
The Vector3 to receive the maximum values.
out
)

Returns: The vector specified with the out argument

public Vector3
getMin(final Vector3
The Vector3 to receive the minimum values.
out
)

Returns: The vector specified with the out argument

public float
public BoundingBox

Returns:

This bounding box for chaining.
inf
()

Sets the minimum and maximum vector to positive and negative infinity.

public boolean

Returns:

Whether the given bounding box is intersected
intersects
(BoundingBox
The bounding box
b
)

Returns whether the given bounding box is intersecting this bounding box (at least one point in).

public boolean

Returns:

True in case the bounding box is valid, false otherwise
isValid
()

Returns whether this bounding box is valid.

pack-priv static final float
max(final float a, final float b)

pack-priv static final float
min(final float a, final float b)

public BoundingBox

Returns:

This bounding box for chaining.
mul
(Matrix4
The matrix
transform
)

Multiplies the bounding box by the given matrix.

public BoundingBox

Returns:

This bounding box for chaining.
set
(BoundingBox
The bounds.
bounds
)

Sets the given bounding box.

public BoundingBox

Returns:

This bounding box for chaining.
set
(Vector3
The minimum vector
minimum
,
Vector3
The maximum vector
maximum
)

Sets the given minimum and maximum vector.

public BoundingBox

Returns:

This bounding box for chaining.
set
(Vector3[]
The points.
points
)

Sets the bounding box minimum and maximum vector from the given points.

public BoundingBox

Returns:

This bounding box for chaining.
set
(List<Vector3>
The points.
points
)

Sets the bounding box minimum and maximum vector from the given points.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
update()

Should be called if you modify min and/or max vectors manually.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

cntback to summary
private final Vector3 cnt
dimback to summary
private final Vector3 dim
maxback to summary
public final Vector3 max

Maximum vector. All XYZ components should be superior to corresponding min components. Call update() if you manually change this vector.

minback to summary
public final Vector3 min

Minimum vector. All XYZ components should be inferior to corresponding max components. Call update() if you manually change this vector.

serialVersionUIDback to summary
private static final long serialVersionUID
tmpVectorback to summary
private static final Vector3 tmpVector

Constructor Detail

BoundingBoxback to summary
public BoundingBox()

Constructs a new bounding box with the minimum and maximum vector set to zeros.

BoundingBoxback to summary
public BoundingBox(BoundingBox bounds)

Constructs a new bounding box from the given bounding box.

Parameters
bounds:BoundingBox

The bounding box to copy

BoundingBoxback to summary
public BoundingBox(Vector3 minimum, Vector3 maximum)

Constructs the new bounding box using the given minimum and maximum vector.

Parameters
minimum:Vector3

The minimum vector

maximum:Vector3

The maximum vector

Method Detail

clrback to summary
public BoundingBox clr()

Sets the minimum and maximum vector to zeros.

Returns:BoundingBox

This bounding box for chaining.

containsback to summary
public boolean contains(BoundingBox b)

Returns whether the given bounding box is contained in this bounding box.

Parameters
b:BoundingBox

The bounding box

Returns:boolean

Whether the given bounding box is contained

containsback to summary
public boolean contains(OrientedBoundingBox obb)

Returns whether the given oriented bounding box is contained in this oriented bounding box.

Parameters
obb:OrientedBoundingBox

The bounding box

Returns:boolean

Whether the given oriented bounding box is contained

containsback to summary
public boolean contains(Vector3 v)

Returns whether the given vector is contained in this bounding box.

Parameters
v:Vector3

The vector

Returns:boolean

Whether the vector is contained or not.

extback to summary
public BoundingBox ext(Vector3 point)

Extends the bounding box to incorporate the given Vector3.

Parameters
point:Vector3

The vector

Returns:BoundingBox

This bounding box for chaining.

extback to summary
public BoundingBox ext(BoundingBox a_bounds)

Extends this bounding box by the given bounding box.

Parameters
a_bounds:BoundingBox

The bounding box

Returns:BoundingBox

This bounding box for chaining.

extback to summary
public BoundingBox ext(Vector3 center, float radius)

Extends this bounding box by the given sphere.

Parameters
center:Vector3

Sphere center

radius:float

Sphere radius

Returns:BoundingBox

This bounding box for chaining.

extback to summary
public BoundingBox ext(BoundingBox bounds, Matrix4 transform)

Extends this bounding box by the given transformed bounding box.

Parameters
bounds:BoundingBox

The bounding box

transform:Matrix4

The transformation matrix to apply to bounds, before using it to extend this bounding box.

Returns:BoundingBox

This bounding box for chaining.

extback to summary
public BoundingBox ext(float x, float y, float z)

Extends the bounding box by the given vector.

Parameters
x:float

The x-coordinate

y:float

The y-coordinate

z:float

The z-coordinate

Returns:BoundingBox

This bounding box for chaining.

getCenterback to summary
public Vector3 getCenter(Vector3 out)
Parameters
out:Vector3

The Vector3 to receive the center of the bounding box.

Returns:Vector3

The vector specified with the out argument.

getCenterXback to summary
public float getCenterX()
getCenterYback to summary
public float getCenterY()
getCenterZback to summary
public float getCenterZ()
getCorner000back to summary
public Vector3 getCorner000(final Vector3 out)
getCorner001back to summary
public Vector3 getCorner001(final Vector3 out)
getCorner010back to summary
public Vector3 getCorner010(final Vector3 out)
getCorner011back to summary
public Vector3 getCorner011(final Vector3 out)
getCorner100back to summary
public Vector3 getCorner100(final Vector3 out)
getCorner101back to summary
public Vector3 getCorner101(final Vector3 out)
getCorner110back to summary
public Vector3 getCorner110(final Vector3 out)
getCorner111back to summary
public Vector3 getCorner111(final Vector3 out)
getDepthback to summary
public float getDepth()
getDimensionsback to summary
public Vector3 getDimensions(final Vector3 out)
Parameters
out:Vector3

The Vector3 to receive the dimensions of this bounding box on all three axis.

Returns:Vector3

The vector specified with the out argument

getHeightback to summary
public float getHeight()
getMaxback to summary
public Vector3 getMax(final Vector3 out)
Parameters
out:Vector3

The Vector3 to receive the maximum values.

Returns:Vector3

The vector specified with the out argument

getMinback to summary
public Vector3 getMin(final Vector3 out)
Parameters
out:Vector3

The Vector3 to receive the minimum values.

Returns:Vector3

The vector specified with the out argument

getWidthback to summary
public float getWidth()
infback to summary
public BoundingBox inf()

Sets the minimum and maximum vector to positive and negative infinity.

Returns:BoundingBox

This bounding box for chaining.

intersectsback to summary
public boolean intersects(BoundingBox b)

Returns whether the given bounding box is intersecting this bounding box (at least one point in).

Parameters
b:BoundingBox

The bounding box

Returns:boolean

Whether the given bounding box is intersected

isValidback to summary
public boolean isValid()

Returns whether this bounding box is valid. This means that max is greater than or equal to min.

Returns:boolean

True in case the bounding box is valid, false otherwise

maxback to summary
pack-priv static final float max(final float a, final float b)
minback to summary
pack-priv static final float min(final float a, final float b)
mulback to summary
public BoundingBox mul(Matrix4 transform)

Multiplies the bounding box by the given matrix. This is achieved by multiplying the 8 corner points and then calculating the minimum and maximum vectors from the transformed points.

Parameters
transform:Matrix4

The matrix

Returns:BoundingBox

This bounding box for chaining.

setback to summary
public BoundingBox set(BoundingBox bounds)

Sets the given bounding box.

Parameters
bounds:BoundingBox

The bounds.

Returns:BoundingBox

This bounding box for chaining.

setback to summary
public BoundingBox set(Vector3 minimum, Vector3 maximum)

Sets the given minimum and maximum vector.

Parameters
minimum:Vector3

The minimum vector

maximum:Vector3

The maximum vector

Returns:BoundingBox

This bounding box for chaining.

setback to summary
public BoundingBox set(Vector3[] points)

Sets the bounding box minimum and maximum vector from the given points.

Parameters
points:Vector3[]

The points.

Returns:BoundingBox

This bounding box for chaining.

setback to summary
public BoundingBox set(List<Vector3> points)

Sets the bounding box minimum and maximum vector from the given points.

Parameters
points:List<Vector3>

The points.

Returns:BoundingBox

This bounding box for chaining.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
updateback to summary
public void update()

Should be called if you modify min and/or max vectors manually.