AABB2
Classes
Axis-Aligned Bounding Box in 2D
Functions
AABB2
Axis-Aligned Bounding Box in 2D
Kind: global class
- AABB2
- new AABB2([x0], [y0], [x1], [y1])
- instance
- .x0 :
number - .y0 :
number - .x1 :
number - .y1 :
number - .0 ⇒
number - .1 ⇒
number - .2 ⇒
number - .3 ⇒
number - .0
- .1
- .2
- .3
- .centerX ⇒
number - .centerY ⇒
number - .width ⇒
number - .height ⇒
number - .isAABB2 :
boolean - .growWidth(size)
- .growHeight(size)
- .grow(size)
- .shrink(size)
- .applyMatrix3(m)
- .multiplyScalar(value)
- .computeOverlap(other, result) ⇒
boolean - .overlapExists(other) ⇒
boolean - ._expandToFit(x0, y0, x1, y1)
- ._expandToFitPoint(x, y)
- .lineIntersectionPoint(p0, p1, result) ⇒
boolean - .computeNearestPointToPoint(point, result)
- .costForInclusion(other) ⇒
number - ._costForInclusion(x0, y0, x1, y1) ⇒
number - .computeArea() ⇒
number - .computeSurfaceArea() ⇒
number - .containsPoint(x, y) ⇒
boolean - .expandToFit(other)
- .getCenter([result])
.midX() ⇒number.midY() ⇒number.getWidth() ⇒number.getHeight() ⇒number- .set(x0, y0, x1, y1) ⇒
this - .setPosition(x, y)
- .move(deltaX, deltaY) ⇒
this - .clone() ⇒
AABB2 - .copy(other) ⇒
AABB2 - .equals(other) ⇒
boolean - .hash() ⇒
number - .clamp(x0, y0, x1, y1)
- .setBoundsUnordered(x0, y0, x1, y1)
- .setNegativelyInfiniteBounds() ⇒
this - .toArray(target, offset) ⇒
Array.<number>|Float32Array
- .x0 :
- static
new AABB2([x0], [y0], [x1], [y1])
| Param | Type | Default |
|---|---|---|
| [x0] | number | 0 |
| [y0] | number | 0 |
| [x1] | number | 0 |
| [y1] | number | 0 |
aabB2.x0 : number
Kind: instance property of AABB2
aabB2.y0 : number
Kind: instance property of AABB2
aabB2.x1 : number
Kind: instance property of AABB2
aabB2.y1 : number
Kind: instance property of AABB2
aabB2.0 ⇒ number
Kind: instance property of AABB2
aabB2.1 ⇒ number
Kind: instance property of AABB2
aabB2.2 ⇒ number
Kind: instance property of AABB2
aabB2.3 ⇒ number
Kind: instance property of AABB2
aabB2.0
Kind: instance property of AABB2
| Param | Type |
|---|---|
| value | number |
aabB2.1
Kind: instance property of AABB2
| Param | Type |
|---|---|
| value | number |
aabB2.2
Kind: instance property of AABB2
| Param | Type |
|---|---|
| value | number |
aabB2.3
Kind: instance property of AABB2
| Param | Type |
|---|---|
| value | number |
aabB2.centerX ⇒ number
midpoint along X axis
Kind: instance property of AABB2
aabB2.centerY ⇒ number
midpoint along Y axis
Kind: instance property of AABB2
aabB2.width ⇒ number
Kind: instance property of AABB2
aabB2.height ⇒ number
Kind: instance property of AABB2
aabB2.isAABB2 : boolean
Kind: instance property of AABB2
Read only: true
aabB2.growWidth(size)
Kind: instance method of AABB2
| Param | Type |
|---|---|
| size | number |
aabB2.growHeight(size)
Kind: instance method of AABB2
| Param | Type |
|---|---|
| size | number |
aabB2.grow(size)
Expands box in every direction by a given amount
Kind: instance method of AABB2
| Param | Type |
|---|---|
| size | number |
aabB2.shrink(size)
Shrinks the box in every direction by a given amount
Kind: instance method of AABB2
| Param | Type |
|---|---|
| size | number |
aabB2.applyMatrix3(m)
Kind: instance method of AABB2
| Param | Type |
|---|---|
| m | Array.<number> |
aabB2.multiplyScalar(value)
Kind: instance method of AABB2
| Param | Type |
|---|---|
| value | number |
aabB2.computeOverlap(other, result) ⇒ boolean
Kind: instance method of AABB2
Returns: boolean - true if there is overlap, result is also written. false otherwise
| Param | Type | Description |
|---|---|---|
| other | AABB2 | |
| result | AABB2 | Overlapping region will be written here |
aabB2.overlapExists(other) ⇒ boolean
Kind: instance method of AABB2
| Param | Type |
|---|---|
| other | AABB2 |
aabB2._expandToFit(x0, y0, x1, y1)
Kind: instance method of AABB2
Access: public
| Param | Type |
|---|---|
| x0 | Number |
| y0 | Number |
| x1 | Number |
| y1 | Number |
aabB2._expandToFitPoint(x, y)
Kind: instance method of AABB2
| Param | Type |
|---|---|
| x | number |
| y | number |
aabB2.lineIntersectionPoint(p0, p1, result) ⇒ boolean
NOTE: only 1 intersection point is produced
Kind: instance method of AABB2
| Param | Type |
|---|---|
| p0 | Vector2 |
| p1 | Vector2 |
| result | Vector2 |
aabB2.computeNearestPointToPoint(point, result)
Kind: instance method of AABB2
| Param | Type |
|---|---|
| point | Vector2 |
| result | Vector2 |
aabB2.costForInclusion(other) ⇒ number
Kind: instance method of AABB2
| Param | Type |
|---|---|
| other | AABB2 |
aabB2._costForInclusion(x0, y0, x1, y1) ⇒ number
Kind: instance method of AABB2
| Param | Type |
|---|---|
| x0 | number |
| y0 | number |
| x1 | number |
| y1 | number |
aabB2.computeArea() ⇒ number
Kind: instance method of AABB2
aabB2.computeSurfaceArea() ⇒ number
Kind: instance method of AABB2
aabB2.containsPoint(x, y) ⇒ boolean
Kind: instance method of AABB2
| Param | Type |
|---|---|
| x | number |
| y | number |
aabB2.expandToFit(other)
Kind: instance method of AABB2
| Param | Type |
|---|---|
| other | AABB2 |
aabB2.getCenter([result])
Kind: instance method of AABB2
| Param | Type |
|---|---|
| [result] | Vector2 |
aabB2.midX() ⇒ number
numberuse centerX instead
retrieve midpoint of AABB along X axis
Kind: instance method of AABB2
aabB2.midY() ⇒ number
numberuse centerY instead
retrieve midpoint of AABB along Y axis
Kind: instance method of AABB2
aabB2.getWidth() ⇒ number
numberprefer to use width property instead
Kind: instance method of AABB2
aabB2.getHeight() ⇒ number
numberprefer to use height property instead
Kind: instance method of AABB2
aabB2.set(x0, y0, x1, y1) ⇒ this
Kind: instance method of AABB2
See: setBoundsUnordered
| Param | Type |
|---|---|
| x0 | Number |
| y0 | Number |
| x1 | Number |
| y1 | Number |
aabB2.setPosition(x, y)
Kind: instance method of AABB2
| Param | Type |
|---|---|
| x | number |
| y | number |
aabB2.move(deltaX, deltaY) ⇒ this
Relative displacement of the AABB by given vector described by deltaX and deltaY
Kind: instance method of AABB2
| Param | Type | Description |
|---|---|---|
| deltaX | number | displacement in X |
| deltaY | number | displacement in Y |
aabB2.clone() ⇒ AABB2
Kind: instance method of AABB2
aabB2.copy(other) ⇒ AABB2
Kind: instance method of AABB2
Returns: AABB2 - this
| Param | Type |
|---|---|
| other | AABB2 |
aabB2.equals(other) ⇒ boolean
Kind: instance method of AABB2
| Param | Type |
|---|---|
| other | AABB2 |
aabB2.hash() ⇒ number
Kind: instance method of AABB2
aabB2.clamp(x0, y0, x1, y1)
Clamps AABB to specified region
Kind: instance method of AABB2
| Param | Type |
|---|---|
| x0 | number |
| y0 | number |
| x1 | number |
| y1 | number |
aabB2.setBoundsUnordered(x0, y0, x1, y1)
Set bounds without having to maintain constraint that x0 >= x1 and y0 >= y1
Kind: instance method of AABB2
| Param | Type |
|---|---|
| x0 | number |
| y0 | number |
| x1 | number |
| y1 | number |
aabB2.setNegativelyInfiniteBounds() ⇒ this
Kind: instance method of AABB2
aabB2.toArray(target, offset) ⇒ Array.<number> | Float32Array
Kind: instance method of AABB2
| Param | Type | Default |
|---|---|---|
| target | Array.<number> | Float32Array | |
| offset | number | 0 |
AABB2.computeLineBetweenTwoBoxes
Alias
Kind: static property of AABB2
AABB2.zero : AABB2
Useful singleton with bounds 0,0,0,0.
Kind: static property of AABB2
Read only: true
Example
const box = new AABB();
// ...
box.copy(AABB.zero); // zero out
AABB2.unit : AABB2
Kind: static property of AABB2
Read only: true
computeLineBetweenTwoBoxes(b0, b1, p0, p1) ⇒ boolean
Kind: global function
Returns: boolean - false if no intersection line found
| Param | Type | Description |
|---|---|---|
| b0 | AABB2 | |
| b1 | AABB2 | |
| p0 | Vector2 | resulting line segment point |
| p1 | Vector2 | resulting line segment point |