{"dist":{"shasum":"21f321b03f16a9ae3a7a8971ae6bffce3d2f1a63","tarball":"https://registry.npmjs.org/n-body-pairs/-/n-body-pairs-0.1.0.tgz","integrity":"sha512-aZZ9Efep2HqG3u8WZcIk1oOwrihbFQCnF8jFFz6wAGT9meq4JZPaytGID3MV9EXaI+b+Gl5FE8cO7gPNA3P9qw==","signatures":[{"sig":"MEUCIQCbxSbMxt2qqTJP/EvWGKX0YbC1id/ZoaLsRvbXGpwhHQIgWkY6X3SqgEMuRlzRxprJ106bVJb7ZC0HgCtJj+yj8VM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"pairs.js","name":"n-body-pairs","_from":".","author":{"name":"Mikola Lysenko"},"readme":"n-body-pairs\n============\nGiven a collection of spheres with equal radii, find all pairwise intersections.\n\nUsage\n=====\nFirst install using npm:\n\n    npm install n-body-pairs\n    \nThen use it as follows:\n\n```javascript\n//Load the library, allocate initial data structure for searching in 3-dimensions with initial reserve capacity of 1000 points\nvar nbp = require(\"n-body-pairs\")(3, 1000)\n\n//Create some points\nvar points = [\n  [0, 0, 0],\n  [1, 0, 0],\n  [0, 1, 0],\n  [0, 0, 100000000],\n  [0, 0, 100000001]\n]\n\n//Report all pairs of points which are within 0.6 units of eachother\nnbp(points, 0.6, function(i,j,d2) {\n    console.log(\"Overlap (\"+i+\",\"+j+\") Distance=\", Math.sqrt(d2), \"Positions=\", points[i], points[j])\n})\n//Prints:\n//\n//  Overlap (0,3) Distance= 1 Positions= [ 0, 0, 0 ] [ 0, 0, 1 ]\n//  Overlap (2,0) Distance= 1 Positions= [ 0, 1, 0 ] [ 0, 0, 0 ]\n//  Overlap (1,0) Distance= 1 Positions= [ 1, 0, 0 ] [ 0, 0, 0 ]\n//  Overlap (4,5) Distance= 1 Positions= [ 0, 0, 100000000 ] [ 0, 0, 100000001 ]\n//\n```\n\n### `var nbp = require(\"n-body-pairs\")(dimension, capacity)`\nAllocates a data structure for performing n-body neighborhood queries.\n\n* `dimension` is the dimension of the space to search in (default 2)\n* `capacity` is the initial size of the data structure to reserve (default 1000)\n\n**Storage Complexity:** `O(capacity * 2^dimension)`\n\n### `nbp(points, radius, callback(a,b,d2))`\nComputes all pairwise overlaps.  If the data structure does not have sufficient capacity, it is resized.\n\n* `points` is an array of points\n* `radius` is the radius of the overlap query\n* `callback(a,b,d2)` is a function which is called on each pair of overlapping points.  If it returns a truthy value, then iteration is terminated.  The parameters are as follows:\n    + `a` index of first point\n    + `b` index of second point\n    + `d2` squared distance between `a` and `b`\n\n**Time Complexity:** `O(points.length * dimension * 2^dimension * log(points.length) + number of intersections)`\n\n### `nbp.capacity`\nReturns the size of the data structure (set to 0 to free memory.  Set to change the reserve capacity of the data structure.\n\nCredits\n=======\n(c) 2013 Mikola Lysenko. BSD License\n","gitHead":"ee6f5c7993073cb19fc9bb1bc19cbf9e29fc11e1","license":"BSD","scripts":{"test":"tap test/*.js"},"_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"keywords":["point","pairs","overlap","n","body","collision","detect","detection","collide","simulate","sphere","radius"],"repository":{"url":"git://github.com/mikolalysenko/n-body-pairs.git","type":"git"},"_npmVersion":"1.2.14","description":"Given a collection of spheres with equal radii, find all pairwise intersections.","directories":{"test":"test"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"dependencies":{},"readmeFilename":"README.md","devDependencies":{"tap":"~0.4.1"},"_id":"n-body-pairs@0.1.0","version":"0.1.0"}