简体   繁体   English

高效的搜索算法可计算线段集上的横截面

[英]Efficient search algorithms to calculate crosssection on set of linesegments

I have a large dataset of linesegments. 我有一个很大的线段数据集。 Each linesegment consists of [x-start,x-end] . 每个线段都由[x-start,x-end] I'm searching for an efficient algorithms to calculate for a given x position the set of intersecting lines. 我正在寻找一种有效的算法来计算给定的x位置的相交线集。

在此处输入图片说明

yves-daoust的回答:间隔树是您最好的朋友

  1. Find all lines where x ∈ [start; 找到x∈[开始; end] in O(n) 结束]在O(n)中
  2. In found list of lines find the line with minimum start and the line with maximum end (in linear time). 在找到的行列表中,找到起点最小的线和终点最大的线(线性时间)。 So you will have two points (A,B) 因此,您将获得两点(A,B)
  3. Find all lines where: 查找以下所有行:

    • A ∈ [start; A∈[开始; end] 结束]
    • B ∈ [start; B∈[开始; end] 结束]
    • start ∈ [A; 开始∈[A; B] and end ∈ [A, B] and put them into Set. B]和结束∈[A,B]并将它们放入Set中。

Overall time complexity should be O(n) 总时间复杂度应为O(n)

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

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