force-n-body
v1.0.7
Published
Force-n-body algorithm with Barnes-Hut Algorithm acceleration.
Downloads
4
Readme
force-n-body
Force-n-body algorithm with Barnes-Hut Algorithm acceleration.
API
nodes
: nodes to compute forcesweightFunc
: each node's weight specifying function, default is() => 30
- return: force vectors array
function forceNBody(
nodes: { x: number; y: number }[],
weightFunc?: (node?: { x: number; y: number }) => number
): { vx: number; vy: number }[];
function forceNBodyBruteForce(
nodes: { x: number; y: number }[],
weightFunc?: (node?: { x: number; y: number }) => number
): { vx: number; vy: number }[];
Reference
- http://arborjs.org/docs/barnes-hut
- https://github.com/d3/d3-force