- 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.0.0
- Author:
- William Bittle
-
-
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.String
toString()
-
Methods inherited from class AbstractBounds
getTranslation, shift, translate, translate
-
Methods inherited from interface Bounds
getTranslation
-
Methods inherited from interface Translatable
translate, translate
-
-
-
-
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
-
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
-
-