Represents two sets of coordinates, minimum and maximum for each direction; thus defining an
axis-aligned cuboid with floating-point boundaries. It supports operations changing the size and
position of the box, as well as querying whether a point or another BoundingBox is inside the box.
All the points within the coordinate limits (inclusive the edges) are considered "inside" the box.
However, for intersection purposes, if the intersection is "sharp" in any coord (min1 == max2, i. e.
zero volume), the boxes are considered non-intersecting.
Name | Parameters | Return value | Notes |
() (constructor) |
MinX, MaxX, MinY, MaxY, MinZ, MaxZ |
cBoundingBox |
Creates a new bounding box with the specified edges |
() (constructor) |
OtherBoundingBox |
cBoundingBox |
Creates a new copy of the given bounding box. Same result can be achieved by using a simple assignment. |
() (constructor) |
Min, Max |
cBoundingBox |
Creates a new bounding box with the coords specified as two vectors |
() (constructor) |
Pos, CubeSideLength |
cBoundingBox |
Creates a new bounding box as a cube with the specified side length centered around the specified point. |
() (constructor) |
Pos, Radius, Height |
cBoundingBox |
Creates a new bounding box from the position given and radius (X/Z) and height. Radius is added from X/Z to calculate the maximum coords and subtracted from X/Z to get the minimum; minimum Y is set to Pos.y and maxumim Y to Pos.y plus Height. This corresponds with how entities are represented in Minecraft. |
CalcLineIntersection |
BoxMin, BoxMax, LineStart, LinePt2 |
DoesIntersect, [LineCoeff, Face] |
(STATIC) Calculates the intersection of a ray (half-line), given by two of its points, with the bounding box specified as its minimum and maximum coords. Returns false if the line doesn't intersect the bounding box, or true, together with coefficient of the intersection (how much of the difference between the two ray points is needed to reach the intersection), and the face of the box which is intersected. |
CalcLineIntersection |
LineStart, LinePt2 |
DoesIntersect, [LineCoeff, Face] |
Calculates the intersection of a ray (half-line), given by two of its points, with the bounding box. Returns false if the line doesn't intersect the bounding box, or true, together with coefficient of the intersection (how much of the difference between the two ray points is needed to reach the intersection), and the face of the box which is intersected. |
DoesIntersect |
OtherBoundingBox |
bool |
Returns true if the two bounding boxes have an intersection of nonzero volume. |
Expand |
ExpandX, ExpandY, ExpandZ |
|
Expands this bounding box by the specified amount in each direction (so the box becomes larger by 2 * Expand in each axis). |
GetMax |
|
Point |
Returns the boundary point with the maximum coords |
GetMaxX |
|
number |
Returns the maximum X coord of the bounding box |
GetMaxY |
|
number |
Returns the maximum Y coord of the bounding box |
GetMaxZ |
|
number |
Returns the maximum Z coord of the bounding box |
GetMin |
|
Point |
Returns the boundary point with the minimum coords |
GetMinX |
|
number |
Returns the minimum X coord of the bounding box |
GetMinY |
|
number |
Returns the minimum Y coord of the bounding box |
GetMinZ |
|
number |
Returns the minimum Z coord of the bounding box |
Intersect |
OtherBbox |
bool, [bbox] |
Checks if the intersection between this bounding box and another one is non-empty. Returns false if the intersection is empty, true and a new cBoundingBox representing the intersection of the two boxes. |
IsInside |
OtherBoundingBox |
bool |
Returns true if OtherBoundingBox is inside of this box. |
IsInside |
PointX, PointY, PointZ |
bool |
Returns true if the specified point is inside (including on the edge) of the box. |
IsInside |
Min, Max, X, Y, Z |
boolean |
(STATIC) Returns true if the specified point is inside the bounding box specified by its min / max corners |
IsInside |
Min, Max, Point |
boolean |
(STATIC) Returns true if the specified point is inside the bounding box specified by its min / max corners |
IsInside |
OtherBoxMin, OtherBoxMax |
bool |
Returns true if the other bounding box, specified by its 2 corners, is inside of this box. |
IsInside |
Point |
bool |
Returns true if the specified point is inside (including on the edge) of the box. |
Move |
OffsetX, OffsetY, OffsetZ |
|
Moves the bounding box by the specified offset in each axis |
Move |
Offset |
|
Moves the bounding box by the specified offset in each axis |
Union |
OtherBoundingBox |
cBoundingBox |
Returns the smallest bounding box that contains both OtherBoundingBox and this bounding box. Note that unlike the strict geometrical meaning of "union", this operation actually returns a cBoundingBox. |