2.1.0 • Published 6 years ago

q43 v2.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Q43

A Quadtree class for JS/ES

Install

npm i q43

API

Q43(ax, ay, bx, by, cap) ⇒ Q43

Create a Q43 instance

Kind: global function

ParamTypeDescription
axNumberminimum X of the Q43 boundary
ayNumberminimum Y of the Q43 boundary
bxNumbermaximum X of the Q43 boundary
byNumbermaximum Y of the Q43 boundary
capNumberThe amount of points a Q43 instance can store.

containsX(px) ⇒ Boolean

Check if x is within the Q43's x-axis

Kind: global function

ParamType
pxNumber

containsY(py) ⇒ Boolean

Check if y is within the Q43's x-axis

Kind: global function

ParamType
pyNumber

containsPoint(px, py) ⇒ Boolean

Check if point is within the Q43's x-axis

Kind: global function

ParamType
pxNumber
pyNumber

subdivide()

Subdivide the Q43 into four equal parts.

Kind: global function

insert(pt) ⇒ Boolean

Insert a point to the Q43

Kind: global function

ParamType
ptArray

remove(pt) ⇒ Boolean

Remove a point from the Q43

Kind: global function

ParamType
ptArray

query(cond) ⇒ Array

Get all points from the Q43 given a condition

Kind: global function Returns: Array - - array of points

ParamTypeDescription
condfunctionthe filter function

all() ⇒ Array

Get all points from the Q43

Kind: global function Returns: Array - - array of points

queryBounds(ax, ay, bx, by, cond) ⇒ Array

Get all points from a Q43 that is within a given boundary and passes the condition

Kind: global function Returns: Array - - array of points

ParamTypeDescription
axNumberminimum x of the given boundary
ayNumberminimum y of the given boundary
bxNumbermaximum x of the given boundary
byNumbermaximum y of the given boundary
condfunctiona filter function, optional

queryRange(px, py, radius, cond) ⇒ Array

Gets all points within the radius of another point from the Q43

Kind: global function

ParamTypeDescription
pxNumber
pyNumber
radiusNumber
condfunctionfilter function, optional

for(handler)

Iterates all points in the Q43 and passes them to a handler function

Kind: global function

ParamType
handlerfunction

forBounds(ax, ay, bx, by, handler)

Iterates all points in the Q43 that are within the bounds and passes them to a handler function. Kind: global function

ParamType
axNumber
ayNumber
bxNumber
byNumber
handlerfunction

forRange(px, py, radius, handler)

Iterates all points within the radius of another point in the Q43 and passes them to a handler.

Kind: global function

ParamType
pxNumber
pyNumber
radiusNumber
handlerfunction

rebuild() ⇒ Q43

This is useful for rebuilding a quadtree whose points have updated coordinates.

Kind: global function

update()

Unlike the rebuild method, the update method does not restore subdivided empty Q43s.

Kind: global function

size() ⇒ Number

Calculates the amount of points a Q43 has.

Kind: global function

draw(ctx, tree, point)

For debugging purposes

Kind: global function

ParamType
ctxCanvasRenderingContext2D
treeBoolean
pointBoolean