Fast algorithm to find all points inside a rectangle

前端 未结 5 752
忘了有多久
忘了有多久 2021-02-14 17:04

Given a set of distinct points in 2D space, and a rectangle (coordinates of all four points, sides parallel with xy axis) how can I quickly find which points are inside the rect

5条回答
  •  南方客
    南方客 (楼主)
    2021-02-14 17:36

    Along with other answers, you can also look into Morton codes (z-order curve sorting).

    In your case, that is static data, you can even represent the whole point data as an array.

    https://en.wikipedia.org/wiki/Z-order_curve

    This paper also have a rather complicated timeline of different "multi-dimentional access methods" --http://www.cc.gatech.edu/computing/Database/readinggroup/articles/p170-gaede.pdf

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题