We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I originally posted this issue to knn, but I realised that the issue was due to a limitation here (#19).
If there are 2 nearest nodes with the exact same distance to the test node, the returned node will always be the last one. Example:
var points = [ { x: 1, y: 2, label: 'A' }, { x: 3, y: 4, label: 'B' }, { x: 5, y: 6, label: 'C' }, { x: 5, y: 6, label: 'E' }, { x: 7, y: 8, label: 'D' }, ]; var distance = function (a, b) { return Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2); } var tree = new kdTree(points, distance, ["x", "y"]); var nearest = tree.nearest({ x: 5, y: 5 }, 1); console.log(nearest); // > [ [ { x: 5, y: 6, label: 'E' }, 1 ] ]
Both node E and node C have the same distance from the test node (distance=1), yet node E is always returned no matter what.
Expected behaviour: If multiple nodes could be chosen as the nearest node and maxNodes is set to 1, the returned node should be chosen at random.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I originally posted this issue to knn, but I realised that the issue was due to a limitation here (#19).
If there are 2 nearest nodes with the exact same distance to the test node, the returned node will always be the last one.
Example:
Both node E and node C have the same distance from the test node (distance=1), yet node E is always returned no matter what.
Expected behaviour:
If multiple nodes could be chosen as the nearest node and maxNodes is set to 1, the returned node should be chosen at random.
The text was updated successfully, but these errors were encountered: