org.spongepowered.api.util

## Class AABB

• ```public class AABB
extends Object```
An axis aligned bounding box. That is, an un-rotated cuboid. It is represented by its minimum and maximum corners.

The box will never be degenerate: the corners are always not equal and respect the minimum and maximum properties.

This class is immutable, all objects returned are either new instances or itself.

• ### Constructor Summary

Constructors
Constructor and Description
```AABB(double x1, double y1, double z1, double x2, double y2, double z2)```
Constructs a new bounding box from two opposite corners.
```AABB(Vector3d firstCorner, Vector3d secondCorner)```
Constructs a new bounding box from two opposite corners.
```AABB(Vector3i firstCorner, Vector3i secondCorner)```
Constructs a new bounding box from two opposite corners.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`boolean` ```contains(double x, double y, double z)```
Checks if the bounding box contains a point.
`boolean` `contains(Vector3d point)`
Checks if the bounding box contains a point.
`boolean` `contains(Vector3i point)`
Checks if the bounding box contains a point.
`boolean` `equals(Object other)`
`AABB` ```expand(double x, double y, double z)```
Expands this bounding box by a given amount in both directions and returns a new box.
`AABB` `expand(Vector3d amount)`
Expands this bounding box by a given amount in both directions and returns a new box.
`AABB` `expand(Vector3i amount)`
Expands this bounding box by a given amount in both directions and returns a new box.
`Vector3d` `getCenter()`
Returns the center of the box, halfway between each corner.
`Vector3d` `getMax()`
The maximum corner of the box.
`Vector3d` `getMin()`
The minimum corner of the box.
`Vector3d` `getSize()`
Gets the size of the box.
`int` `hashCode()`
`boolean` `intersects(AABB other)`
Checks if the bounding box intersects another.
`Optional<Tuple<Vector3d,Vector3d>>` ```intersects(Vector3d start, Vector3d direction)```
Tests for intersection between the box and a ray defined by a starting point and a direction.
`AABB` ```offset(double x, double y, double z)```
Offsets this bounding box by a given amount and returns a new box.
`AABB` `offset(Vector3d offset)`
Offsets this bounding box by a given amount and returns a new box.
`AABB` `offset(Vector3i offset)`
Offsets this bounding box by a given amount and returns a new box.
`String` `toString()`
• ### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
• ### Constructor Detail

• #### AABB

```public AABB(Vector3i firstCorner,
Vector3i secondCorner)```
Constructs a new bounding box from two opposite corners. Fails the resulting box would be degenerate (a dimension is 0).
Parameters:
`firstCorner` - The first corner
`secondCorner` - The second corner
• #### AABB

```public AABB(double x1,
double y1,
double z1,
double x2,
double y2,
double z2)```
Constructs a new bounding box from two opposite corners. Fails the resulting box would be degenerate (a dimension is 0).
Parameters:
`x1` - The first corner x coordinate
`y1` - The first corner y coordinate
`z1` - The first corner z coordinate
`x2` - The second corner x coordinate
`y2` - The second corner y coordinate
`z2` - The second corner z coordinate
• #### AABB

```public AABB(Vector3d firstCorner,
Vector3d secondCorner)```
Constructs a new bounding box from two opposite corners. Fails the resulting box would be degenerate (a dimension is 0).
Parameters:
`firstCorner` - The first corner
`secondCorner` - The second corner
• ### Method Detail

• #### getMin

`public Vector3d getMin()`
The minimum corner of the box.
Returns:
The minimum corner
• #### getMax

`public Vector3d getMax()`
The maximum corner of the box.
Returns:
The maximum corner
• #### getCenter

`public Vector3d getCenter()`
Returns the center of the box, halfway between each corner.
Returns:
The center
• #### getSize

`public Vector3d getSize()`
Gets the size of the box.
Returns:
The size
• #### contains

`public boolean contains(Vector3i point)`
Checks if the bounding box contains a point.
Parameters:
`point` - The point to check
Returns:
Whether or not the box contains the point
• #### contains

`public boolean contains(Vector3d point)`
Checks if the bounding box contains a point.
Parameters:
`point` - The point to check
Returns:
Whether or not the box contains the point
• #### contains

```public boolean contains(double x,
double y,
double z)```
Checks if the bounding box contains a point.
Parameters:
`x` - The x coordinate of the point
`y` - The y coordinate of the point
`z` - The z coordinate of the point
Returns:
Whether or not the box contains the point
• #### intersects

`public boolean intersects(AABB other)`
Checks if the bounding box intersects another.
Parameters:
`other` - The other bounding box to check
Returns:
Whether this bounding box intersects with the other
• #### intersects

```public Optional<Tuple<Vector3d,Vector3d>> intersects(Vector3d start,
Vector3d direction)```
Tests for intersection between the box and a ray defined by a starting point and a direction.
Parameters:
`start` - The starting point of the ray
`direction` - The direction of the ray
Returns:
An intersection point its normal, if any
• #### offset

`public AABB offset(Vector3i offset)`
Offsets this bounding box by a given amount and returns a new box.
Parameters:
`offset` - The offset to apply
Returns:
The new offset box
• #### offset

`public AABB offset(Vector3d offset)`
Offsets this bounding box by a given amount and returns a new box.
Parameters:
`offset` - The offset to apply
Returns:
The new offset box
• #### offset

```public AABB offset(double x,
double y,
double z)```
Offsets this bounding box by a given amount and returns a new box.
Parameters:
`x` - The amount of offset for the x coordinate
`y` - The amount of offset for the y coordinate
`z` - The amount of offset for the z coordinate
Returns:
The new offset box
• #### expand

`public AABB expand(Vector3i amount)`
Expands this bounding box by a given amount in both directions and returns a new box. The expansion is applied half and half to the minimum and maximum corners.
Parameters:
`amount` - The amount of expansion to apply
Returns:
The new expanded box
• #### expand

`public AABB expand(Vector3d amount)`
Expands this bounding box by a given amount in both directions and returns a new box. The expansion is applied half and half to the minimum and maximum corners.
Parameters:
`amount` - The amount of expansion to apply
Returns:
The new expanded box
• #### expand

```public AABB expand(double x,
double y,
double z)```
Expands this bounding box by a given amount in both directions and returns a new box. The expansion is applied half and half to the minimum and maximum corners.
Parameters:
`x` - The amount of expansion for the x coordinate
`y` - The amount of expansion for the y coordinate
`z` - The amount of expansion for the z coordinate
Returns:
The new expanded box
• #### equals

`public boolean equals(Object other)`
Overrides:
`equals` in class `Object`
• #### hashCode

`public int hashCode()`
Overrides:
`hashCode` in class `Object`
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`