API Docs for: 0.3
Show:

Grid Class

Module: Common
Parent Module: CrowdSim

Grid hashmap to store entities indexed by their position.

Constructor

Grid

(
  • near
)

Parameters:

  • near Number

    is the cell size for the hashmap. Also the maximum distance to be consider "neighbours"

Methods

_key

(
  • entity
  • x
  • y
)
String

Build the key to map coordinates to the hashmap.

Parameters:

  • entity Entity
  • x Number

    coordinate, if null entity.pos[0] is used

  • y Number

    coordinate, if null entity.pos[1] is used

Returns:

String:

key

_keyNeighbours

(
  • x
  • y
)
Array

Builds the keys of the neighbours of the position (x,y).

Parameters:

Returns:

Array:

neighbours keys

clear

()

Clear the hashmap.

insert

(
  • entities
)

Insert entities in the hashmap.

Parameters:

insertOne

(
  • entity
  • x
  • y
)

Insert one entity.

Parameters:

  • entity Entity
  • x Number

    coordinate, if null entity.pos[0] is used

  • y Number

    coordinate, if null entity.pos[1] is used

neighbours

(
  • entity
  • x
  • y
)
LazySequence

Gets neighbours to (x,y) point or Entity.

Parameters:

  • entity Entity
  • x Number

    coordinate, if null entity.pos[0] is used

  • y Number

    coordinate, if null entity.pos[1] is used

Returns:

LazySequence:

neighbours

neighboursContext

(
  • context
)
LazySequence

Gets neighbours to a context by sampling its position with the cell size.

Parameters:

Returns:

LazySequence:

neighbours

remove

(
  • entities
)

Remove the given entities.

Parameters:

update

(
  • entities
)

Update given entities mapping.

Parameters:

updateAll

(
  • entities
)

Clear the hashamp and insert entities.

Parameters:

updateContextsHelper

(
  • contexts
)

Helper to update multiple contexts area points by sampling their area with the cell size.

Parameters:

updateWallsHelper

(
  • walls
)

Helper to update multiple walls area points by sampling their path with the cell size.

Parameters: