4 algorithm kdtree data-structures
我正在查看KD树最近邻搜索的维基百科页面.
维基百科中给出的伪代码在点为2-D(x,y)时起作用.
我想知道,当点是3-D(x,y,z)时,我应该做出什么改变.
我google了很多,甚至在堆栈溢出中经历了类似的问题链接,但我没有找到任何地方的3-d实现,所有以前的问题都需要2-D点作为输入,而不是我的3-D点寻找.
用于构建KD树的Wiki中的伪代码是::
function kdtree (list of points pointList, int depth)
{
// Select axis based on depth so that axis cycles through all valid values
var int axis := depth mod k;
// Sort point list and choose median as pivot element
select median by axis from pointList;
// Create node and construct subtrees
var tree_node node;
node.location := median;
node.leftChild := kdtree(points in pointList before median, depth+1);
node.rightChild := kdtree(points in pointList after median, depth+1);
return node;
}
Run Code Online (Sandbox Code Playgroud)
如何在建造KD树后找到最近的邻居?
谢谢!
您可以在"最近邻居搜索"标题下的维基百科页面上找到最接近的邻居.这里的描述适用于任何数量的维度.那是:
| 归档时间: |
|
| 查看次数: |
4244 次 |
| 最近记录: |