Finding nearest point in an efficient way

后端 未结 6 1600
野性不改
野性不改 2020-11-30 07:23

I\'ve got a point in 2d plane for example (x0,y0) and a set of n points (x1,y1)...(xn,yn) and I want to find nearest point to (x0,y0) in a way better than trying all points

6条回答
  •  隐瞒了意图╮
    2020-11-30 07:37

    A particularly nice solution is ANN: A Library for Approximate Nearest Neighbor Searching. I've used it for point location in triangulations. You initialize a data structure with points, in my case I used the center points of my triangles. Then you can pass in another point and get back list of the approximate closest neighbour points. Even the number of points returned is selectable as a parameter. Anyway ANN was a great library for my purposes, I'd suggest you check it out.

    Good luck!

提交回复
热议问题