BoundingBox


public final class BoundingBox


Represents an axis-aligned bounding box in 3D space, defined by its minimum and maximum corner points.

Summary

Public methods

boolean
equals(Object other)
static final @NonNull BoundingBox
fromCenterAndHalfExtents(
    @NonNull Vector3 center,
    @NonNull FloatSize3d halfExtents
)

Creates a BoundingBox from a center point and its half-extents.

static final @NonNull BoundingBox

Creates a BoundingBox with the given minimum and maximum corner points.

final @NonNull Vector3

the center point of the box

final @NonNull FloatSize3d

the distance from the center to each face of the box along the axes.

final @NonNull Vector3

a Vector3 representing the maximum corner of the box (highest x, y, and z values)

final @NonNull Vector3

a Vector3 representing the minimum corner of the box (lowest x, y, and z values)

int
@NonNull String

Public methods

equals

public boolean equals(Object other)

fromCenterAndHalfExtents

Added in 1.0.0-alpha10
public static final @NonNull BoundingBox fromCenterAndHalfExtents(
    @NonNull Vector3 center,
    @NonNull FloatSize3d halfExtents
)

Creates a BoundingBox from a center point and its half-extents.

This factory method ensures that the created bounding box is valid by checking that all components of center and halfExtents are not NaN, and that each component of halfExtents is greater than or equal to zero.

Parameters
@NonNull Vector3 center

the center point of the box. Its components must not be NaN

@NonNull FloatSize3d halfExtents

the distance from the center to each face of the box. Its components must not be NaN and must be greater than or equal to zero

Returns
@NonNull BoundingBox

a new BoundingBox instance

Throws
IllegalArgumentException

if any component of center or halfExtents is NaN, or if any component of halfExtents is negative

fromMinMax

Added in 1.0.0-alpha10
public static final @NonNull BoundingBox fromMinMax(@NonNull Vector3 min, @NonNull Vector3 max)

Creates a BoundingBox with the given minimum and maximum corner points.

This factory method ensures that the created bounding box is valid by checking that all components of min and max are not NaN, and that each component of the min point is less than or equal to the corresponding component of the max point.

Parameters
@NonNull Vector3 min

a Vector3 representing the minimum corner of the box (lowest x, y, and z values). Its components must not be NaN

@NonNull Vector3 max

a Vector3 representing the maximum corner of the box (highest x, y, and z values). Its components must not be NaN

Returns
@NonNull BoundingBox

a new BoundingBox instance

Throws
IllegalArgumentException

if any component of min or max is NaN, or if any component of min is greater than the corresponding component of max

getCenter

Added in 1.0.0-alpha10
public final @NonNull Vector3 getCenter()

the center point of the box

getHalfExtents

Added in 1.0.0-alpha10
public final @NonNull FloatSize3d getHalfExtents()

the distance from the center to each face of the box along the axes. The total width, height, and depth of the box are twice the half-extent values

getMax

Added in 1.0.0-alpha10
public final @NonNull Vector3 getMax()

a Vector3 representing the maximum corner of the box (highest x, y, and z values)

getMin

Added in 1.0.0-alpha10
public final @NonNull Vector3 getMin()

a Vector3 representing the minimum corner of the box (lowest x, y, and z values)

hashCode

public int hashCode()

toString

public @NonNull String toString()