简体   繁体   English

使用 RTrees 搜索网格之间的交集的复杂性

[英]Complexity of searching for intersection between grids with RTrees

I have two grids (coming from finite elements, but this is not relevant), say T_1 , T_2 .我有两个网格(来自有限元,但这不相关),比如T_1T_2 One grid is inside the other, think of a square inside another one for instance.一个网格在另一个网格内,例如,考虑另一个网格内的正方形。 For each grid I have constructed an RTree with boost of bounding boxes, say RTree1 and RTree2 .对于每个网格,我构建了一个带有boost边界框的 RTree,比如RTree1RTree2 To find all the pair of intersecting rectangles, I do the following要找到所有相交的矩形对,我执行以下操作

for (const auto &[box2, cell2] : RTree_2)
      {
        for (const auto &[box1, cell1] :
             RTree1 | bgi::adaptors::queried(bgi::intersects(box2)))
          {
             do_something_with_cells(cell1,cell2);

          }
      }
  }

Let's say that I have N bounding boxes for the first tree and M bounding boxes for the second tree.假设我有第一棵树的N个边界框和第二棵树的M个边界框。 I want to determine the complexity of the snippet above.我想确定上面代码段的复杂性。 Since the intersection has a complexity which is O(log(N)) (on average), I think the snippet above has a complexity which is O(NM log(N)) .由于交叉点的复杂度为O(log(N)) (平均而言),我认为上面的代码段的复杂度为O(NM log(N)) Is this correct?这个对吗?

Since the intersection has a complexity which is O(log(N))由于交叉点的复杂度为 O(log(N))

What intersection are you talking about here?你说的是哪个路口? If you're talking about the entirety of the query (which seems to make most sense due to your inclusion of N ), then you should not have to multiply N again outside the query.如果您正在谈论整个query (由于包含N ,这似乎最有意义),那么您不必在查询之外再次乘以N I think it is O(M log(N) therefore.我认为它是O(M log(N)因此。

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

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