331 lines
6.5 KiB
Markdown
Raw Permalink Normal View History

2020-07-28 20:21:55 -07:00
[Planck.js API Doc](../README.md) › [Globals](../globals.md) › [AABB](aabb.md)
# Class: AABB
## Hierarchy
* **AABB**
## Index
2021-04-16 17:10:15 +02:00
### Constructors
* [constructor](aabb.md#constructor)
2020-07-28 20:21:55 -07:00
### Properties
* [lowerBound](aabb.md#lowerbound)
* [upperBound](aabb.md#upperbound)
### Methods
* [combine](aabb.md#combine)
* [combinePoints](aabb.md#combinepoints)
* [contains](aabb.md#contains)
* [extend](aabb.md#extend)
* [getCenter](aabb.md#getcenter)
* [getExtents](aabb.md#getextents)
* [getPerimeter](aabb.md#getperimeter)
* [isValid](aabb.md#isvalid)
* [rayCast](aabb.md#raycast)
* [set](aabb.md#set)
* [toString](aabb.md#tostring)
2021-04-16 17:10:15 +02:00
* [areEqual](aabb.md#static-areequal)
* [assert](aabb.md#static-assert)
* [diff](aabb.md#static-diff)
* [extend](aabb.md#static-extend)
* [isValid](aabb.md#static-isvalid)
* [testOverlap](aabb.md#static-testoverlap)
## Constructors
### constructor
\+ **new AABB**(`lower?`: [Vec2](vec2.md), `upper?`: [Vec2](vec2.md)): *[AABB](aabb.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:56](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L56)*
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
`lower?` | [Vec2](vec2.md) |
`upper?` | [Vec2](vec2.md) |
**Returns:** *[AABB](aabb.md)*
2020-07-28 20:21:55 -07:00
## Properties
### lowerBound
• **lowerBound**: *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:55](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L55)*
2020-07-28 20:21:55 -07:00
___
### upperBound
• **upperBound**: *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:56](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L56)*
2020-07-28 20:21:55 -07:00
## Methods
2021-04-16 17:10:15 +02:00
### combine
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
▸ **combine**(`a`: [AABB](aabb.md), `b?`: [AABB](aabb.md)): *void*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:121](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L121)*
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
Combine one or two AABB into this one.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [AABB](aabb.md) |
2021-05-11 18:30:36 -07:00
`b?` | [AABB](aabb.md) |
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
**Returns:** *void*
2020-07-28 20:21:55 -07:00
___
2021-04-16 17:10:15 +02:00
### combinePoints
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **combinePoints**(`a`: [Vec2](vec2.md), `b`: [Vec2](vec2.md)): *void*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:138](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L138)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
2021-04-16 17:10:15 +02:00
`a` | [Vec2](vec2.md) |
`b` | [Vec2](vec2.md) |
2020-07-28 20:21:55 -07:00
**Returns:** *void*
___
2021-04-16 17:10:15 +02:00
### contains
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **contains**(`aabb`: [AABB](aabb.md)): *boolean*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:148](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L148)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
2021-04-16 17:10:15 +02:00
`aabb` | [AABB](aabb.md) |
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
**Returns:** *boolean*
2020-07-28 20:21:55 -07:00
___
2021-04-16 17:10:15 +02:00
### extend
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **extend**(`value`: number): *[AABB](aabb.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:157](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L157)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
2021-04-16 17:10:15 +02:00
`value` | number |
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
**Returns:** *[AABB](aabb.md)*
2020-07-28 20:21:55 -07:00
___
2021-04-16 17:10:15 +02:00
### getCenter
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **getCenter**(): *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:100](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L100)*
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
Get the center of the AABB.
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
**Returns:** *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
___
2021-04-16 17:10:15 +02:00
### getExtents
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **getExtents**(): *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:107](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L107)*
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
Get the extents of the AABB (half-widths).
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
**Returns:** *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
___
2021-04-16 17:10:15 +02:00
### getPerimeter
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **getPerimeter**(): *number*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:114](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L114)*
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
Get the perimeter length.
2020-07-28 20:21:55 -07:00
**Returns:** *number*
___
2021-04-16 17:10:15 +02:00
### isValid
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **isValid**(): *boolean*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:79](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L79)*
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
Verify that the bounds are sorted.
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
**Returns:** *boolean*
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
___
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
### rayCast
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **rayCast**(`output`: [RayCastOutput](../interfaces/raycastoutput.md), `input`: [RayCastInput](../interfaces/raycastinput.md)): *boolean*
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:199](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L199)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
2021-04-16 17:10:15 +02:00
`output` | [RayCastOutput](../interfaces/raycastoutput.md) |
`input` | [RayCastInput](../interfaces/raycastinput.md) |
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
**Returns:** *boolean*
2020-07-28 20:21:55 -07:00
___
2021-04-16 17:10:15 +02:00
### set
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **set**(`aabb`: [AABB](aabb.md)): *void*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:143](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L143)*
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
`aabb` | [AABB](aabb.md) |
**Returns:** *void*
2020-07-28 20:21:55 -07:00
___
2021-04-16 17:10:15 +02:00
### toString
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **toString**(): *string*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:260](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L260)*
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
**Returns:** *string*
2020-07-28 20:21:55 -07:00
___
2021-04-16 17:10:15 +02:00
### `Static` areEqual
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **areEqual**(`a`: [AABB](aabb.md), `b`: [AABB](aabb.md)): *boolean*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:182](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L182)*
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [AABB](aabb.md) |
`b` | [AABB](aabb.md) |
**Returns:** *boolean*
2020-07-28 20:21:55 -07:00
___
2021-04-16 17:10:15 +02:00
### `Static` assert
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **assert**(`o`: any): *void*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:89](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L89)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`o` | any |
2021-04-16 17:10:15 +02:00
**Returns:** *void*
2020-07-28 20:21:55 -07:00
___
2021-04-16 17:10:15 +02:00
### `Static` diff
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **diff**(`a`: [AABB](aabb.md), `b`: [AABB](aabb.md)): *number*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:186](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L186)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
2021-04-16 17:10:15 +02:00
`a` | [AABB](aabb.md) |
`b` | [AABB](aabb.md) |
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
**Returns:** *number*
2020-07-28 20:21:55 -07:00
___
2021-04-16 17:10:15 +02:00
### `Static` extend
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **extend**(`aabb`: [AABB](aabb.md), `value`: number): *void*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:162](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L162)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`aabb` | [AABB](aabb.md) |
2021-04-16 17:10:15 +02:00
`value` | number |
2020-07-28 20:21:55 -07:00
**Returns:** *void*
___
2021-04-16 17:10:15 +02:00
### `Static` isValid
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **isValid**(`aabb`: any): *boolean*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:83](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L83)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
2021-04-16 17:10:15 +02:00
`aabb` | any |
2020-07-28 20:21:55 -07:00
**Returns:** *boolean*
___
2021-04-16 17:10:15 +02:00
### `Static` testOverlap
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **testOverlap**(`a`: [AABB](aabb.md), `b`: [AABB](aabb.md)): *boolean*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/collision/AABB.ts:169](https://github.com/shakiba/planck.js/blob/acc3bd8/src/collision/AABB.ts#L169)*
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [AABB](aabb.md) |
`b` | [AABB](aabb.md) |
**Returns:** *boolean*