BoundingBox

data class BoundingBox(val minX: Double, val minY: Double, val minZ: Double, val maxX: Double, val maxY: Double, val maxZ: Double) : Record

An area in 3D space defined by two sets of points, a minimum and a maximum.

This area forms a box, which can be used for collision detection. If a bounding box intersects with something, we know that the two objects are colliding.

This is immutable, and as such, any method that would alter the state of the bounding box returns a new instance with the requested changes.

Constructors

Link copied to clipboard
constructor(min: Vec3d, max: Vec3d)

Creates a new bounding box with the given min and max values.

constructor(min: Vec3i, max: Vec3i)

Creates a new bounding box with the given min and max values.

constructor(minX: Double, minY: Double, minZ: Double, maxX: Double, maxY: Double, maxZ: Double)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun center(): Vec3d

Gets a vector representing the center of this bounding box on the X, Y, and Z axes.

Link copied to clipboard

Checks if the given x, y, and z values are inside the bounds of this box.

Link copied to clipboard
fun contract(amount: Vec3d): BoundingBox

Contracts this bounding box by the given amount and returns the result.

Contracts this bounding box by the given x, y, and z amounts and returns the result.

Link copied to clipboard
fun deflate(factor: Double): BoundingBox

Deflates this bounding box by the given factor and returns the result.

Deflates this bounding box by the given x, y, and z amounts and returns the result.

Link copied to clipboard
fun expand(amount: Double): BoundingBox
fun expand(amount: Vec3d): BoundingBox

Expands this bounding box by the given amount and returns the result.

Expands this bounding box by the given x, y, and z amounts and returns the result.

Link copied to clipboard
fun inflate(factor: Double): BoundingBox

Deflates this bounding box by the given factor and returns the result.

Inflates this bounding box by the given x, y, and z amounts and returns the result.

Link copied to clipboard

Intersects this bounding box with the given other box and returns the result.

Link copied to clipboard

Checks if this bounding box intersects with the given other box.

Link copied to clipboard
fun max(): Vec3d

Gets the maximum vector of this bounding box.

Gets the maximum value on the given axis.

Link copied to clipboard
fun min(): Vec3d

Gets the minimum vector of this bounding box.

Gets the minimum value on the given axis.

Link copied to clipboard
fun move(amount: Double): BoundingBox
fun move(amount: Vec3d): BoundingBox

Moves this bounding box by the given amount and returns the result.

Moves this bounding box by the given x, y, and z amounts and returns the result.

Link copied to clipboard
fun size(): Vec3d

Gets a vector representing the size of this bounding box on the X, Y, and Z axes.

Link copied to clipboard

Calculates the total size of this bounding box.

Link copied to clipboard
fun volume(): Double

Calculates the volume of this bounding box.

Properties

Link copied to clipboard

The maximum X value.

Link copied to clipboard

The maximum Y value.

Link copied to clipboard

The maximum Z value.

Link copied to clipboard

The minimum X value.

Link copied to clipboard

The minimum Y value.

Link copied to clipboard

The minimum Z value.