简体   繁体   English

Octree最近的邻居搜索

[英]Nearest neighbor search in Octree

How does a NN algorithm work on an octree? NN算法如何在八叉树上工作? I have searched for a good explanation, but most of the time people just say used KD-tree instead. 我一直在寻找一个很好的解释,但是大多数时候人们只是说使用KD-tree。 I cant do it, i need to visualize NN algorithm on octree step-by-step. 我做不到,我需要一步一步地可视化NN算法。

As i can think the most logical way would be to: 我认为最合乎逻辑的方式是:

1) Find the sub-octant where the point belongs to. 1)找到该点所属的子八分位。

2) Calculate distance to the nearest point in that octant 2)计算到该八分位数中最近点的距离

3) Check if there is any overlap with neighboring octants within that distance 3)检查在该距离内是否与相邻八分圆重叠

4) If a closer point is found, recalculate the search distance. 4)如果找到较近的点,请重新计算搜索距离。

5) Repeat until all possible octants have been traversed 5)重复直到遍历所有可能的八分圆

6) Return the closest point 6)返回最接近的点

But i cant think up a good step by step visualization for this one. 但是我不能为此想出一个很好的逐步可视化方法。

To find the point closest to a search point, or to get list of points in order of increasing distance, you can use a priority queue that can hold both points and internal nodes of the tree, which lets you remove them in order of distance. 要查找最接近搜索点的点,或按距离增加的顺序获取点列表,可以使用优先级队列,该队列可以同时包含点和树的内部节点,从而可以按距离顺序将其删除。

For points (leaves), the distance is just the distance of the point from the search point. 对于点(叶),距离就是该点到搜索点的距离。 For internal nodes (octants), the distance is the smallest distance from the search point to any point that could possibly be in the octant. 对于内部节点(八分圆),该距离是从搜索点到可能在八分圆中的任何点的最小距离。

Now, to search, you just put the root of the tree in the priority queue, and repeat: 现在,要进行搜索,只需将树的根放在优先级队列中,然后重复:

  1. Remove the head of the priority queue; 删除优先级队列的头部;
  2. If the head of the queue was a point, then it is the closest point in the tree that you have not yet returned. 如果队列的开头是一个点,则它是树中尚未返回的最接近的点。 You know this, because if any internal node could possibly have a closer point, then it would have been returned first from the priority queue; 您知道这一点,因为如果任何内部节点可能有一个更近的点,那么它将首先从优先级队列中返回;
  3. If the head of the queue was an internal node, then put its children back into the queue 如果队列的头是一个内部节点,则将其子级放回队列

This will produce all the points in the tree in order of increasing distance from the search point. 这将按与搜索点的距离增加的顺序生成树中的所有点。 The same algorithm works for KD trees as well. 相同的算法也适用于KD树。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM