public class AABB extends Object
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 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(com.flowpowered.math.vector.Vector3d firstCorner,
com.flowpowered.math.vector.Vector3d secondCorner)
Constructs a new bounding box from two opposite corners.
|
AABB(com.flowpowered.math.vector.Vector3i firstCorner,
com.flowpowered.math.vector.Vector3i secondCorner)
Constructs a new bounding box from two opposite corners.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(double x,
double y,
double z)
Checks if the bounding box contains a point.
|
boolean |
contains(com.flowpowered.math.vector.Vector3d point)
Checks if the bounding box contains a point.
|
boolean |
contains(com.flowpowered.math.vector.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(com.flowpowered.math.vector.Vector3d amount)
Expands this bounding box by a given amount in both directions and
returns a new box.
|
AABB |
expand(com.flowpowered.math.vector.Vector3i amount)
Expands this bounding box by a given amount in both directions and
returns a new box.
|
com.flowpowered.math.vector.Vector3d |
getCenter()
Returns the center of the box, halfway between each corner.
|
com.flowpowered.math.vector.Vector3d |
getMax()
The maximum corner of the box.
|
com.flowpowered.math.vector.Vector3d |
getMin()
The minimum corner of the box.
|
com.flowpowered.math.vector.Vector3d |
getSize()
Gets the size of the box.
|
int |
hashCode() |
boolean |
intersects(AABB other)
Checks if the bounding box intersects another.
|
Optional<Tuple<com.flowpowered.math.vector.Vector3d,com.flowpowered.math.vector.Vector3d>> |
intersects(com.flowpowered.math.vector.Vector3d start,
com.flowpowered.math.vector.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(com.flowpowered.math.vector.Vector3d offset)
Offsets this bounding box by a given amount and returns a new box.
|
AABB |
offset(com.flowpowered.math.vector.Vector3i offset)
Offsets this bounding box by a given amount and returns a new box.
|
String |
toString() |
public AABB(com.flowpowered.math.vector.Vector3i firstCorner,
com.flowpowered.math.vector.Vector3i secondCorner)
firstCorner - The first cornersecondCorner - The second cornerpublic AABB(double x1,
double y1,
double z1,
double x2,
double y2,
double z2)
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 coordinatepublic AABB(com.flowpowered.math.vector.Vector3d firstCorner,
com.flowpowered.math.vector.Vector3d secondCorner)
firstCorner - The first cornersecondCorner - The second cornerpublic com.flowpowered.math.vector.Vector3d getMin()
public com.flowpowered.math.vector.Vector3d getMax()
public com.flowpowered.math.vector.Vector3d getCenter()
public com.flowpowered.math.vector.Vector3d getSize()
public boolean contains(com.flowpowered.math.vector.Vector3i point)
point - The point to checkpublic boolean contains(com.flowpowered.math.vector.Vector3d point)
point - The point to checkpublic boolean contains(double x,
double y,
double z)
x - The x coordinate of the pointy - The y coordinate of the pointz - The z coordinate of the pointpublic boolean intersects(AABB other)
other - The other bounding box to checkpublic Optional<Tuple<com.flowpowered.math.vector.Vector3d,com.flowpowered.math.vector.Vector3d>> intersects(com.flowpowered.math.vector.Vector3d start, com.flowpowered.math.vector.Vector3d direction)
start - The starting point of the raydirection - The direction of the raypublic AABB offset(com.flowpowered.math.vector.Vector3i offset)
offset - The offset to applypublic AABB offset(com.flowpowered.math.vector.Vector3d offset)
offset - The offset to applypublic AABB offset(double x, double y, double z)
x - The amount of offset for the x coordinatey - The amount of offset for the y coordinatez - The amount of offset for the z coordinatepublic AABB expand(com.flowpowered.math.vector.Vector3i amount)
amount - The amount of expansion to applypublic AABB expand(com.flowpowered.math.vector.Vector3d amount)
amount - The amount of expansion to applypublic AABB expand(double x, double y, double z)
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