# Class: Box2

## Box2(min, max)

#### new Box2(min, max)

Box is described by a minimum and maximum points. Can be used for collision detection with points and other boxes.

##### Parameters:

Name | Type | Description
--- | --- | ---
`min` | Vector2 | Minimum point of the box.
`max` | Vector2 | Maximum point of the box.

Source:
  - math/Box2.js, line 12

### Members

#### max :Vector2

Maximum point of the box.

##### Type:

- Vector2

Source:
  - math/Box2.js, line 26

#### min :Vector2

Minimum point of the box.

##### Type:

- Vector2

Source:
  - math/Box2.js, line 19

### Methods

#### clone() → {Box2}

Clone the box into a new object. Should be used when it it necessary to make operations to this box.

Source:
  - math/Box2.js, line 84

##### Returns:

New box object with the copy of this object.

Type
  Box2

#### containsBox(box) → {boolean}

Check if the box fully contains another box inside (different from intersects box). Only returns true if the box is fully contained.

##### Parameters:

Name | Type | Description
--- | --- | ---
`box` | Box2 |

Source:
  - math/Box2.js, line 206

##### Returns:

True if the box contains box.

Type
  boolean

#### containsPoint(point) → {boolean}

Check if the box contains a point inside.

##### Parameters:

Name | Type | Description
--- | --- | ---
`point` | Vector2 |

Source:
  - math/Box2.js, line 193

##### Returns:

True if the box contains point.

Type
  boolean

#### copy(point)

Copy the box value from another box.

##### Parameters:

Name | Type | Description
--- | --- | ---
`point` | Box2 |

Source:
  - math/Box2.js, line 96

#### distanceToPoint(point) → {number}

Calculate the distance to a point.

##### Parameters:

Name | Type | Description
--- | --- | ---
`point` | Vector2 |

Source:
  - math/Box2.js, line 228

##### Returns:

Distance to point calculated.

Type
  number

#### equals(box) → {boolean}

Checks if two boxes are equal.

##### Parameters:

Name | Type | Description
--- | --- | ---
`box` | Box2 |

Source:
  - math/Box2.js, line 278

##### Returns:

True if the two boxes are equal.

Type
  boolean

#### expandByPoint(point)

Expand the box to contain a new point.

##### Parameters:

Name | Type | Description
--- | --- | ---
`point` | Vector2 |

Source:
  - math/Box2.js, line 155

#### expandByScalar(scalar)

Expand the box by adding a border with the scalar value.

##### Parameters:

Name | Type | Description
--- | --- | ---
`scalar` | number |

Source:
  - math/Box2.js, line 181

#### expandByVector(vector)

Expand the box by adding a border with the vector size. Vector is subtracted from min and added to the max points.

##### Parameters:

Name | Type | Description
--- | --- | ---
`vector` | Vector2 |

Source:
  - math/Box2.js, line 170

#### fromArray(array)

Set box data min and max from numeric array.

##### Parameters:

Name | Type | Description
--- | --- | ---
`array` | Array.<number> | Numeric array with box data min and max.

Source:
  - math/Box2.js, line 298

#### getCenter(targetopt) → {Vector2}

Calculate the center point of the box.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`target` | Vector2 | <optional> | Vector to store the result.

Source:
  - math/Box2.js, line 120

##### Returns:

Central point of the box.

Type
  Vector2

#### getSize(targetopt) → {Vector2}

Get the size of the box from its min and max points.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`target` | Vector2 | <optional> | Vector to store the result.

Source:
  - math/Box2.js, line 138

##### Returns:

Vector with the calculated size.

Type
  Vector2

#### intersect(box)

Make a intersection between this box and another box. Store the result in this object.

##### Parameters:

Name | Type | Description
--- | --- | ---
`box` | Box2 |

Source:
  - math/Box2.js, line 242

#### intersectsBox(box) → {boolean}

Check if two boxes intersect each other, using 4 splitting planes to rule out intersections.

##### Parameters:

Name | Type | Description
--- | --- | ---
`box` | Box2 |

Source:
  - math/Box2.js, line 217

##### Returns:

True if the boxes intersect each other.

Type
  boolean

#### isEmpty() → {boolean}

Check if the box is empty (size equals zero or is negative). The box size is condireded valid on two negative axis.

Source:
  - math/Box2.js, line 109

##### Returns:

True if the box is empty.

Type
  boolean

#### set(min, max)

Set the box values.

##### Parameters:

Name | Type | Description
--- | --- | ---
`min` | Vector2 | Minimum point of the box.
`max` | Vector2 | Maximum point of the box.

Source:
  - math/Box2.js, line 35

#### setFromCenterAndSize(center, size)

Set the box minimum and maximum from center point and size.

##### Parameters:

Name | Type | Description
--- | --- | ---
`center` | Vector2 |
`size` | Vector2 |

Source:
  - math/Box2.js, line 67

#### setFromPoints(points)

Set the box from a list of Vector2 points.

##### Parameters:

Name | Type | Description
--- | --- | ---
`points` | Array |

Source:
  - math/Box2.js, line 48

#### toArray() → {Array.<number>}

Store the box data into a numeric array.

Source:
  - math/Box2.js, line 288

##### Returns:

Numeric array with box data min and max.

Type
  Array.<number>

#### translate(offset)

Translate the box by a offset value, adds the offset to booth min and max.

##### Parameters:

Name | Type | Description
--- | --- | ---
`offset` | Vector2 |

Source:
  - math/Box2.js, line 266

#### union(box)

Make a union between this box and another box. Store the result in this object.

##### Parameters:

Name | Type | Description
--- | --- | ---
`box` | Box2 |

Source:
  - math/Box2.js, line 255