0.0.1 • Published 3 years ago
rbush-3d-knn v0.0.1
rbush-3d-knn
k-nearest neighbors search for RBush-3D. Implements a simple depth-first kNN search algorithm using a priority queue.
var RBush = require('rbush-3d');
var knn = require('rbush-knn');
var tree = new RBush(); // create RBush tree
tree.load(data); // bulk insert
var neighbors = knn(tree, 40, 40, 40, 10); // return 10 nearest items around point [40, 40, 40]You can optionally pass a filter function to find k neighbors that satisfy a certain condition:
var neighbors = knn(tree, 40, 40, 40, 10, function (item) {
return item.foo === 'bar';
});API
knn(tree, x, y, z, k, filterFn, maxDistance)
tree: an RBush treex,y,z: query coordinatesk: number of neighbors to search for (Infinityby default)filterFn: optional filter function;knearest items wherefilterFn(item) === truewill be returned.maxDistance(optional): maximum distance between neighbors and the query coordinates (Infinityby default)
Changelog
0.0.1 (Nov 12, 2020)
- Rework rbush-knn to work with rbush-3d
0.0.1
3 years ago