Class: AABB

AABB(x, y, width, height)

Class representing an Axis-Aligned Bounding Box.

Constructor

new AABB(x, y, width, height)

Create an AABB using centre position, width, and height.

Parameters:
Name Type Description
x number

The x value of the centre.

y number

The y value of the centre.

width number

The width measured from the centre.

height number

The height measured from the centre.

Source:

Classes

AABB

Methods

contains(point) → {boolean}

Check if this AABB contains a Vector.

Parameters:
Name Type Description
point Vector

The vector to check.

Source:
Returns:
Type
boolean

intersects(range) → {boolean}

Check if this AABB intersects another AABB.

Parameters:
Name Type Description
range AABB

The target AABB to check.

Source:
Returns:
Type
boolean

lines() → {Array.<Line>}

Create an array of Lines containing one line for each side of the AABB.

Parameters:
Name Type Attributes Description
options.stroke string <optional>
options.strokeWidth number <optional>
Source:
Returns:
  • An array of Lines that can be added to a Plot using Plot#add.
Type
Array.<Line>

(static) fromCorners(topLeft, topRight, bottomRight, bottomLeft) → {AABB}

Create an AABB from four corner Vectors.

Parameters:
Name Type Description
topLeft Vector
topRight Vector
bottomRight Vector
bottomLeft Vector
Source:
Returns:
  • A new AABB object.
Type
AABB