public 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 methods

final @NonNull MutableVec

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

final void
computeCorners(
    @NonNull MutableVec outVecXMinYMin,
    @NonNull MutableVec outVecXMaxYMin,
    @NonNull MutableVec outVecXMaxYMax,
    @NonNull MutableVec outVecXMinYMax
)

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

final boolean
contains(@NonNull Box otherBox)

Returns whether the other Box is contained within this Box.

final boolean

Returns whether the given point is contained within the Box.

final @FloatRange(from = 0.0) float

The height of the rectangle.

final @FloatRange(from = 0.0) 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.

final boolean
isAlmostEqual(@NonNull Box other, @FloatRange(from = 0.0) float tolerance)

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 methods

computeCenter

Added in 1.0.0-alpha01
public final @NonNull MutableVec computeCenter(@NonNull MutableVec outVec)

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

computeCorners

Added in 1.0.0-alpha01
public final void computeCorners(
    @NonNull MutableVec outVecXMinYMin,
    @NonNull MutableVec outVecXMaxYMin,
    @NonNull MutableVec outVecXMaxYMax,
    @NonNull MutableVec outVecXMinYMax
)

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
public final boolean contains(@NonNull Box otherBox)

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
public final boolean contains(@NonNull Vec point)

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

getHeight

Added in 1.0.0-alpha01
public final @FloatRange(from = 0.0) float getHeight()

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

getWidth

Added in 1.0.0-alpha01
public final @FloatRange(from = 0.0) float getWidth()

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

getXMax

Added in 1.0.0-alpha01
public abstract float getXMax()

The upper bound in the X direction.

getXMin

Added in 1.0.0-alpha01
public abstract float getXMin()

The lower bound in the X direction.

getYMax

Added in 1.0.0-alpha01
public abstract float getYMax()

The upper bound in the Y direction.

getYMin

Added in 1.0.0-alpha01
public abstract float getYMin()

The lower bound in the Y direction.

isAlmostEqual

Added in 1.0.0-alpha01
public final boolean isAlmostEqual(@NonNull Box other, @FloatRange(from = 0.0) float tolerance)

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.