abstract class Box

Known direct subclasses
ImmutableBox

An immutable axis-aligned rectangle.

MutableBox

A mutable axis-aligned rectangle.


Represents an axis-aligned rectangle. See ImmutableBox and MutableBox for concrete classes implementing Box.

The Box interface is the read-only view of the underlying data which may or may not be mutable.

Summary

Public functions

MutableVec

Populates outVec with the center of the Box, and returns outVec.

Unit
computeCorners(
    outVecXMinYMin: MutableVec,
    outVecXMaxYMin: MutableVec,
    outVecXMaxYMax: MutableVec,
    outVecXMinYMax: MutableVec
)

Populates the 4 output points with the corners of the Box.

operator Boolean
contains(otherBox: Box)

Returns whether the other Box is contained within this Box.

operator Boolean
contains(point: Vec)

Returns whether the given point is contained within the Box.

Boolean
isAlmostEqual(other: Box, tolerance: @FloatRange(from = 0.0) Float)

Compares this Box with other, and returns true if the difference between xMin and other.xMin is less than tolerance, and likewise for xMax, yMin, and yMax.

Public properties

Float

The height of the rectangle.

Float

The width of the rectangle.

abstract Float

The upper bound in the X direction.

abstract Float

The lower bound in the X direction.

abstract Float

The upper bound in the Y direction.

abstract Float

The lower bound in the Y direction.

Public functions

computeCenter

Added in 1.0.0-alpha01
fun computeCenter(outVec: MutableVec): MutableVec

Populates outVec with the center of the Box, and returns outVec.

computeCorners

Added in 1.0.0-alpha01
fun computeCorners(
    outVecXMinYMin: MutableVec,
    outVecXMaxYMin: MutableVec,
    outVecXMaxYMax: MutableVec,
    outVecXMinYMax: MutableVec
): Unit

Populates the 4 output points with the corners of the Box. The order of the corners is: (x_min, y_min), (x_max, y_min), (x_max, y_max), (x_min, y_max)

contains

Added in 1.0.0-alpha01
operator fun contains(otherBox: Box): Boolean

Returns whether the other Box is contained within this Box. Edges of the other Box that overlap with this one's boundary are considered to be contained.

contains

Added in 1.0.0-alpha01
operator fun contains(point: Vec): Boolean

Returns whether the given point is contained within the Box. Points that lie exactly on the Box's boundary are considered to be contained.

isAlmostEqual

Added in 1.0.0-alpha01
fun isAlmostEqual(other: Box, tolerance: @FloatRange(from = 0.0) Float): Boolean

Compares this Box with other, and returns true if the difference between xMin and other.xMin is less than tolerance, and likewise for xMax, yMin, and yMax.

Public properties

height

Added in 1.0.0-alpha01
val heightFloat

The height of the rectangle. This can never be negative.

width

Added in 1.0.0-alpha01
val widthFloat

The width of the rectangle. This can never be negative.

xMax

Added in 1.0.0-alpha01
abstract val xMaxFloat

The upper bound in the X direction.

xMin

Added in 1.0.0-alpha01
abstract val xMinFloat

The lower bound in the X direction.

yMax

Added in 1.0.0-alpha01
abstract val yMaxFloat

The upper bound in the Y direction.

yMin

Added in 1.0.0-alpha01
abstract val yMinFloat

The lower bound in the Y direction.