# Interface AABB

public interface AABB
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.

• ## Nested Class Summary

Nested Classes
Modifier and Type
Interface
Description
`static interface `
`AABB.Factory`

• ## Method Summary

Modifier and Type
Method
Description
`Vector3d`
`center()`
Returns the center of the box, halfway between each corner.
`boolean`
```contains(double x, double y, double z)```
Checks if the bounding box contains a point.
`default boolean`
`contains(Vector3d point)`
Checks if the bounding box contains a point.
`default boolean`
`contains(Vector3i point)`
Checks if the bounding box contains a point.
`AABB`
```expand(double x, double y, double z)```
Expands this bounding box by a given amount in both directions and returns a new box.
`default AABB`
`expand(Vector3d amount)`
Expands this bounding box by a given amount in both directions and returns a new box.
`default AABB`
`expand(Vector3i amount)`
Expands this bounding box by a given amount in both directions and returns a new box.
`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.
`Vector3d`
`max()`
The maximum corner of the box.
`Vector3d`
`min()`
The minimum corner of the box.
`static AABB`
```of(double x1, double y1, double z1, double x2, double y2, double z2)```
Creates a new bounding box from two opposite corners.
`static AABB`
```of(Vector3d v1, Vector3d v2)```
Creates a new bounding box from two opposite corners.
`static AABB`
```of(Vector3i v1, Vector3i v2)```
Creates a new bounding box from two opposite corners.
`AABB`
```offset(double x, double y, double z)```
Offsets this bounding box by a given amount and returns a new box.
`default AABB`
`offset(Vector3d offset)`
Offsets this bounding box by a given amount and returns a new box.
`default AABB`
`offset(Vector3i offset)`
Offsets this bounding box by a given amount and returns a new box.
`Vector3d`
`size()`
Gets the size of the box.
• ## Method Details

• ### of

static AABB of(Vector3d v1, Vector3d v2)
Creates a new bounding box from two opposite corners.

Fails the resulting box would be degenerate (a dimension is 0).

Parameters:
`v1` - The first corner
`v2` - The second corner
Returns:
An AABB
• ### of

static AABB of(Vector3i v1, Vector3i v2)
Creates a new bounding box from two opposite corners.

Fails the resulting box would be degenerate (a dimension is 0).

Parameters:
`v1` - The first corner
`v2` - The second corner
Returns:
An AABB
• ### of

static AABB of(double x1, double y1, double z1, double x2, double y2, double z2)
Creates 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
Returns:
An AABB
• ### min

Vector3d min()
The minimum corner of the box.
Returns:
The minimum corner
• ### max

Vector3d max()
The maximum corner of the box.
Returns:
The maximum corner
• ### center

Vector3d center()
Returns the center of the box, halfway between each corner.
Returns:
The center
• ### size

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

default 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

default 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

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

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

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

default 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

default 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

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

default 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

default 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

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