- Object
-
- AbstractBounds
-
- AxisAlignedBounds
-
- All Implemented Interfaces:
Bounds
,Shiftable
,Translatable
public final class AxisAlignedBounds extends AbstractBounds implements Bounds, Translatable
Represents a bounding region that is an Axis-Aligned bounding box.This class compares its AABB with the AABB of the given body and returns true if they do not overlap.
- Since:
- 3.1.1
- Version:
- 4.2.1
- Author:
- William Bittle
-
-
Field Summary
Fields Modifier and Type Field Description protected AABB
aabb
The local coordinates AABB-
Fields inherited from class AbstractBounds
transform
-
-
Constructor Summary
Constructors Constructor Description AxisAlignedBounds(double width, double height)
Minimal constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AABB
getBounds()
Returns the world space Axis-Aligned bounding box for this bounds object.double
getHeight()
Returns the height of the bounds.double
getWidth()
Returns the width of the bounds.boolean
isOutside(CollisionBody<?> body)
Returns true if the givenCollisionBody
is fully outside the bounds.boolean
isOutside(AABB aabb)
Returns true if the givenAABB
is fully outside the bounds.boolean
isOutside(AABB aabb, Transform transform, Fixture fixture)
String
toString()
-
Methods inherited from class AbstractBounds
getTranslation, shift, translate, translate
-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface Bounds
getTranslation
-
Methods inherited from interface Translatable
translate, translate
-
-
-
-
Field Detail
-
aabb
protected final AABB aabb
The local coordinates AABB
-
-
Constructor Detail
-
AxisAlignedBounds
public AxisAlignedBounds(double width, double height)
Minimal constructor.- Parameters:
width
- the width of the bounds; must be greater than zeroheight
- the height of the bounds; must be greater than zero- Throws:
IllegalArgumentException
- if either width or height are less than or equal to zero
-
-
Method Detail
-
isOutside
public boolean isOutside(CollisionBody<?> body)
Description copied from interface:Bounds
Returns true if the givenCollisionBody
is fully outside the bounds.If the
CollisionBody
contains zeroFixture
s thenCollisionBody
is considered to be outside the bounds.- Specified by:
isOutside
in interfaceBounds
- Parameters:
body
- theCollisionBody
to test- Returns:
- boolean true if outside the bounds
-
isOutside
public boolean isOutside(AABB aabb, Transform transform, Fixture fixture)
Description copied from interface:Bounds
Returns true if the givenAABB
orFixture
is fully outside the bounds.The implementation can use any of the provided information. For example, the
AxisAlignedBounds
class only uses the providedAABB
. For implementations of complex bounds, you can use theTransform
and shape contained in theFixture
.
-
getBounds
public AABB getBounds()
Returns the world space Axis-Aligned bounding box for this bounds object.- Returns:
AABB
-
getWidth
public double getWidth()
Returns the width of the bounds.- Returns:
- double
-
getHeight
public double getHeight()
Returns the height of the bounds.- Returns:
- double
-
-