Count points in a rectangle

前端 未结 9 1438
失恋的感觉
失恋的感觉 2020-12-29 23:53

I have lots (billions) of points in 2D which I can preprocess and I would like to answer queries which are of the following form:

Given all four corners of a rectang

9条回答
  •  生来不讨喜
    2020-12-30 00:32

    A simplification you can make to solve your problem is to find the minimum axis-aligned rectangle (S) containing the one given (R). Use some spatial tree structure as a k-d tree to find the subset of points contained inside S and finally, select for that subset the points that are inside R.

    That approach will be way easier to implement than the one proposed by @Dukelin where the k-d tree search is performed directly using R.

提交回复
热议问题