{"dist":{"shasum":"ffadb125e101bbf4066754394b28359c2e8a02c5","tarball":"https://registry.npmjs.org/n-body-pairs/-/n-body-pairs-0.0.1.tgz","integrity":"sha512-OY5ETkwLQUEKwaqbqt0PowAi6c+2I67ajj/Z8ePQ+IR+3FahFgiY0z6+BSwETR8GxZIxlbPPx6J9dY3bYIFj3Q==","signatures":[{"sig":"MEYCIQDEdj8MS63MuM2KY7noIF+Bvpne70psT5dI1VkD07/aIQIhAN2teU+2QTjX8Dc/2Rz0y/+KIC0oVrZwMJsd2++EuoCN","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\nvar nbp = require(\"n-body-pairs\")\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 1.1 units of eachother\nnbp(points, 1.1, 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### `nbp(points, radius, callback(a,b,d2)[, storage])`\nComputes all pairwise overlaps\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* `storage` an optional storage data structure, created using allocateStorage.  If not specified, it is created upon running the algorithm.\n\n**Time Complexity:** `O(points.length * dimension * 2^dimension * log(points.length) + number of intersections)`\n\n**Space Complexity:** Size of storage is `O(points.length * 2^dimension)`\n\n## Storage\nTo avoid reallocating the array, you can preallocate storage for the data structure.  Here is an example of how to do this:\n\n```javascript\nvar nbp = require(\"n-body-pairs\")\n\n//Reserve storage for 1000 points in 2D\nvar storage = nbp.allocateStorage(1000, 2)\n\n//Now call library as usual, but pass storage as extra argument:\nnbp([[1, 0, 0],[0,0,1]], 1.0, function(i,j,d2) {},  storage)\n```\n\nThis avoids reallocating the intermediate arrays needed to solve for collisions\n\n### `nbp.allocateStorage(max_points, dimension)`\nReserves space for an intermediate storage data structure\n\n* `max_points` is the initial capacity of the storage\n* `dimension` is the dimension of the point set\n\n**Returns:** A new storage object for resolving the overlap queries\n\n### `nbp.resizeStorage(storage, max_points, dimension)`\nResizes the storage data structure\n\n* `storage` is the data structure to resize\n* `max_points` is the new capacity of the storage\n* `dimension` is the dimension of the point set\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.0.1","version":"0.0.1"}