【问题标题】:Finding closest points to given coordinates - data structure查找与给定坐标最近的点 - 数据结构
【发布时间】:2014-12-30 22:59:57
【问题描述】:

什么是保存二维点集合的好数据结构,以便以后我可以有效地调用像 collection.pointsCloserThanDistance(float d, float[] coordinates) 这样的方法? - 此方法将返回一个列表,其中每个点到给定坐标的距离小于或等于 d。

(以及该方法的实现方式如何?)

最简单且可能不太好的解决方案是标准数组,然后将每个点与给定坐标进行比较。这是 O(n),n = 点数。但是可能有 O(m), m = 到给定坐标的距离小于或等于给定值的点数。

【问题讨论】:

    标签: performance graphics data-structures distance point


    【解决方案1】:

    您需要像k-d tree 这样的“空间分区”数据结构。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-30
      • 1970-01-01
      • 1970-01-01
      • 2013-06-28
      • 1970-01-01
      • 1970-01-01
      • 2012-10-24
      • 2020-11-05
      相关资源
      最近更新 更多