# BoundingBox

`verb.core.BoundingBox`

CLASS

Source code

`BoundingBox` is an n-dimensional bounding box implementation. It is used by many of verb's intersection algorithms.

The first point added to the `BoundingBox` using `BoundingBox.add` will be used to define the dimensionality of the bounding box.

## constructor

METHOD

Source code

`new BoundingBox(pts : Array<Point>)`

BoundingBox Constructor

params

• Points to add, if desired. Otherwise, will not be initialized until add is called.

## fromPoint

METHOD

Source code

`fromPoint(pt : undefined)`

Create a bounding box initialized with a single element

params

• A array of numbers

returns

• This BoundingBox for chaining

METHOD

Source code

`add(point : Point) : BoundingBox`

Adds a point to the bounding box, expanding the bounding box if the point is outside of it. If the bounding box is not initialized, this method has that side effect.

params

• A length-n array of numbers

returns

• This BoundingBox for chaining

METHOD

Source code

`addRange(points : Array<Point>) : BoundingBox`

Asynchronously add an array of points to the bounding box

params

• An array of length-n array of numbers

returns

• this BoundingBox for chaining

## contains

METHOD

Source code

`contains(point : Point, tol : Float) : Bool`

Determines if point is contained in the bounding box

params

• the point
• the tolerance

returns

• true if the two intervals overlap, otherwise false

## intervalsOverlap

STATIC METHOD

Source code

`intervalsOverlap(a1 : Float, a2 : Float, b1 : Float, b2 : Float, tol : Float) : Bool`

Determines if two intervals on the real number line intersect

params

• Beginning of first interval
• End of first interval
• Beginning of second interval
• End of second interval

returns

• true if the two intervals overlap, otherwise false

## intersects

METHOD

Source code

`intersects(bb : BoundingBox, tol : Float) : Bool`

Determines if this bounding box intersects with another

params

• BoundingBox to check for intersection with this one

returns

• true if the two bounding boxes intersect, otherwise false

METHOD

Source code

`clear() : BoundingBox`

Clear the bounding box, leaving it in an uninitialized state. Call add, addRange in order to initialize

returns

• this BoundingBox for chaining

## getLongestAxis

METHOD

Source code

`getLongestAxis() : Int`

Get longest axis of bounding box

returns

• Index of longest axis

## getAxisLength

METHOD

Source code

`getAxisLength(i : Int) : Float`

Get length of given axis.

params

• Index of axis to inspect (between 0 and 2)

returns

• Length of the given axis. If axis is out of bounds, returns 0.

## intersect

METHOD

Source code

`intersect(bb : BoundingBox, tol : Float) : BoundingBox`

Compute the boolean intersection of this with another axis-aligned bounding box. If the two bounding boxes do not intersect, returns null.

params

• BoundingBox to intersect with

returns

• The bounding box formed by the intersection or null if there is no intersection.

## min

PROPERTY

Source code

`min : Point`

The minimum point of the BoundingBox - the coordinates of this point are always <= max.

## max

PROPERTY

Source code

`max : Point`

The maximum point of the BoundingBox. The coordinates of this point are always >= min.