BoundingBox

A bounding box is a rectangle that contains a set of points.

Constructor

new BoundingBox(min_x, min_y, width, height)

Creates a new bounding box from a minimum x-coordinate, minimum y-coordinate, width, and height.

Parameters:
NameTypeDescription
min_xnumber

The minimum x-coordinate of the bounding box.

min_ynumber

The minimum y-coordinate of the bounding box.

widthnumber

The width of the bounding box.

heightnumber

The height of the bounding box.

Classes

BoundingBox

Members

center

Returns the center point of the bounding box.

height

Gets the height of the bounding box.

min_x

Gets the minimum x-coordinate of the bounding box.

min_y

Gets the minimum y-coordinate of the bounding box.

width

Gets the width of the bounding box.

Methods

clone() → {BoundingBox}

Clones the bounding box.

Returns:
Type: 
BoundingBox

contains(point) → {boolean}

Checks if a point is contained within the bounding box.

Parameters:
NameTypeDescription
pointPoint2D

The point to check if it is contained within the bounding box.

Returns:

A boolean indicating if the point is contained within the bounding box.

Type: 
boolean

intersects(other) → {boolean}

Checks if the bounding box overlaps with another bounding box.

Parameters:
NameTypeDescription
otherBoundingBox

The other bounding box to check for intersection.

Returns:

A boolean indicating if the bounding box overlaps with the other bounding box.

Type: 
boolean

(static) from_path(path) → {BoundingBox|undefined}

Creates the instance of a path's bounding box.

Parameters:
NameTypeDescription
pathPath2D

The path to calculate the bounding box of.

Returns:

The bounding box of the path.

Type: 
BoundingBox | undefined

(static) intersection(_thisopt, otheropt) → {BoundingBox|undefined}

Returns the intersection of the bounding box with another bounding box, it means the area that is common to both bounding boxes.

Parameters:
NameTypeAttributesDescription
_thisBoundingBox | null<optional>

The bounding box to intersect with.

otherBoundingBox | null<optional>

The other bounding box to intersect with.

Returns:

The intersection of the bounding box with the other bounding box.

Type: 
BoundingBox | undefined

(static) union(_thisopt, otheropt) → {BoundingBox|undefined}

Returns the union of the bounding box with another bounding box, it means the smallest bounding box that contains both bounding boxes.

Parameters:
NameTypeAttributesDescription
_thisBoundingBox | null<optional>

The bounding box to union with.

otherBoundingBox | null<optional>

The other bounding box to union with.

Returns:

The union of the bounding box with the other bounding box.

Type: 
BoundingBox | undefined