Package org.spongepowered.api.util
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
-
Method Summary
Modifier and TypeMethodDescriptioncenter()
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
Checks if the bounding box contains a point.default boolean
Checks if the bounding box contains a point.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
Expands this bounding box by a given amount in both directions and returns a new box.default AABB
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.intersects
(Vector3d start, Vector3d direction) Tests for intersection between the box and a ray defined by a starting point and a direction.max()
The maximum corner of the box.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
Creates a new bounding box from two opposite corners.static AABB
Creates a new bounding box from two opposite corners.offset
(double x, double y, double z) Offsets this bounding box by a given amount and returns a new box.default AABB
Offsets this bounding box by a given amount and returns a new box.default AABB
Offsets this bounding box by a given amount and returns a new box.size()
Gets the size of the box.
-
Method Details
-
of
Creates a new bounding box from two opposite corners.Fails the resulting box would be degenerate (a dimension is 0).
- Parameters:
v1
- The first cornerv2
- The second corner- Returns:
- An AABB
-
of
Creates a new bounding box from two opposite corners.Fails the resulting box would be degenerate (a dimension is 0).
- Parameters:
v1
- The first cornerv2
- The second corner- Returns:
- An AABB
-
of
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 coordinatey1
- The first corner y coordinatez1
- The first corner z coordinatex2
- The second corner x coordinatey2
- The second corner y coordinatez2
- 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
Checks if the bounding box contains a point.- Parameters:
point
- The point to check- Returns:
- Whether or not the box contains the point
-
contains
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 pointy
- The y coordinate of the pointz
- The z coordinate of the point- Returns:
- Whether or not the box contains the point
-
intersects
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
Tests for intersection between the box and a ray defined by a starting point and a direction.- Parameters:
start
- The starting point of the raydirection
- The direction of the ray- Returns:
- An intersection point its normal, if any
-
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
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
Offsets this bounding box by a given amount and returns a new box.- Parameters:
x
- The amount of offset for the x coordinatey
- The amount of offset for the y coordinatez
- The amount of offset for the z coordinate- Returns:
- The new offset box
-
expand
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
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
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 coordinatey
- The amount of expansion for the y coordinatez
- The amount of expansion for the z coordinate- Returns:
- The new expanded box
-