SpacialRectIndex

SpacialRectIndex

2D spatial indexing for rectangles

Methods

getInRadius(x, y, radius) → {Array}

Source:

Get all rects that intersect the circle around x|y

Parameters:
Name Type Description
x Number

coordinate

y Number

coordinate

radius Number

radius

Returns:

array of items in the radius

Type
Array

getInRect(minX, minY, maxX, maxY) → {Array}

Source:

Get all rects that intersect the given rectangle

Parameters:
Name Type Description
minX Number
minY Number
maxX Number
maxY Number
Returns:

array of items in the rectangle

Type
Array

getNearest(x, y, n) → {*|Array}

Source:

Get the nearest rectangle(s) (k-nearest-neighbour)

Parameters:
Name Type Default Description
x Number

coordinate

y Number

coordinate

n Number 1

amount of items to return

Returns:

an item if n = 1, otherwise an array

Type
* | Array