Test point for its position relative to the convex hull in log(n)

后端 未结 6 1312
清歌不尽
清歌不尽 2021-01-04 05:42

I have a collection of 2D points S and I need to test if an input point q is inside or outside the convex hull of S.

Since it\

6条回答
  •  臣服心动
    2021-01-04 06:11

    This problem can be categorized as a classic point-location problem.

    • The preprocessing would include calculating convex hull for the set of points, and the line segments of the convex hull would be used in the next step (or the whole of CH as a region).

    • There are many standard O(log n) query-time algorithms for this kind of problems (http://en.wikipedia.org/wiki/Point_location) like Kirkpatrick triangulation, randomized trapezoidal maps, etc..

    Also note that in expectation, the number of points in CH(S) is O(log N) where N is the number of total points in S. So the number of line segments considered for point location is already reduced to O(log N), which means that the query time is actually O(log log N) in expectation (in terms of total points in S).

提交回复
热议问题