#

API Docs for: 0.6.0
Show: Inherited Protected Private Deprecated

# SAPBroadphase Class

Extends Broadphase
Defined in: `src/collision/SAPBroadphase.js:6`

Sweep and prune broadphase along one axis.

## Constructor

### `SAPBroadphase`

(

- `world`

)

Defined in `src/collision/SAPBroadphase.js:6`

#### Parameters:

- `world` World

- Index
- Methods
- Properties

## Item Index

### Methods

- aabbQuery
- autoDetectAxis
- checkBounds static
- collisionPairs
- doBoundingBoxBroadphase
- doBoundingSphereBroadphase
- insertionSortX static
- insertionSortY static
- insertionSortZ static
- intersectionTest
- makePairsUnique
- needBroadphaseCollision
- setWorld

### Properties

- axisIndex
- axisList
- useBoundingBoxes
- world

## Methods

### `aabbQuery`

(

- `world`
- `aabb`
- `result`

)
Array

Inherited from Broadphase but overwritten in `src/collision/SAPBroadphase.js:280`

Returns all the bodies within an AABB.

#### Parameters:

- `world` World
- `aabb` AABB
- `result` Array

  An array to store resulting bodies in.

#### Returns:

Array:

### `autoDetectAxis`

()

Defined in `src/collision/SAPBroadphase.js:231`

Computes the variance of the body positions and estimates the best axis to use. Will automatically set property .axisIndex.

### `checkBounds`

(

- `bi`
- `bj`
- `axisIndex`

)
Boolean static

Defined in `src/collision/SAPBroadphase.js:204`

Check if the bounds of two bodies overlap, along the given SAP axis.

#### Parameters:

- `bi` Body
- `bj` Body
- `axisIndex` Number

#### Returns:

Boolean:

### `collisionPairs`

(

- `world`
- `p1`
- `p2`

)

Inherited from Broadphase but overwritten in `src/collision/SAPBroadphase.js:143`

Collect all collision pairs

#### Parameters:

- `world` World
- `p1` Array
- `p2` Array

### `doBoundingBoxBroadphase`

(

- `Body`
- `Body`
- `pairs1`
- `pairs2`

)

Inherited from Broadphase: `src/collision/Broadphase.js:123`

Check if the bounding boxes of two bodies are intersecting.

#### Parameters:

- `Body` Object

  bi

- `Body` Object

  bj

- `pairs1` Array
- `pairs2` Array

### `doBoundingSphereBroadphase`

(

- `bi`
- `bj`
- `pairs1`
- `pairs2`

)

Inherited from Broadphase: `src/collision/Broadphase.js:100`

Check if the bounding spheres of two bodies are intersecting.

#### Parameters:

- `bi` Body
- `bj` Body
- `pairs1` Array

  bi is appended to this array if intersection

- `pairs2` Array

  bj is appended to this array if intersection

### `insertionSortX`

(

- `a`

)
Array static

Defined in `src/collision/SAPBroadphase.js:83`

#### Parameters:

- `a` Array

#### Returns:

Array:

### `insertionSortY`

(

- `a`

)
Array static

Defined in `src/collision/SAPBroadphase.js:103`

#### Parameters:

- `a` Array

#### Returns:

Array:

### `insertionSortZ`

(

- `a`

)
Array static

Defined in `src/collision/SAPBroadphase.js:123`

#### Parameters:

- `a` Array

#### Returns:

Array:

### `intersectionTest`

(

- `bodyA`
- `bodyB`
- `pairs1`
- `pairs2`

)

Inherited from Broadphase: `src/collision/Broadphase.js:84`

Check if the bounding volumes of two bodies intersect.

#### Parameters:

- `bodyA` Body
- `bodyB` Body
- `pairs1` Array
- `pairs2` Array

### `makePairsUnique`

(

- `pairs1`
- `pairs2`

)

Inherited from Broadphase: `src/collision/Broadphase.js:151`

Removes duplicate pairs from the pair arrays.

#### Parameters:

- `pairs1` Array
- `pairs2` Array

### `needBroadphaseCollision`

(

- `bodyA`
- `bodyB`

)
Bool

Inherited from Broadphase: `src/collision/Broadphase.js:45`

Check if a body pair needs to be intersection tested at all.

#### Parameters:

- `bodyA` Body
- `bodyB` Body

#### Returns:

Bool:

### `setWorld`

(

- `world`

)

Inherited from Broadphase but overwritten in `src/collision/SAPBroadphase.js:57`

Change the world

#### Parameters:

- `world` World

## Properties

### `axisIndex`

Number

Defined in `src/collision/SAPBroadphase.js:31`

Axis to sort the bodies along. Set to 0 for x axis, and 1 for y axis. For best performance, choose an axis that the bodies are spread out more on.

### `axisList`

Array

Defined in `src/collision/SAPBroadphase.js:17`

List of bodies currently in the broadphase.

### `useBoundingBoxes`

Boolean

Inherited from Broadphase: `src/collision/Broadphase.js:23`

If set to true, the broadphase uses bounding boxes for intersection test, else it uses bounding spheres.

### `world`

World

Inherited from Broadphase but overwritten in `src/collision/SAPBroadphase.js:24`

The world to search in.