How to find the nearest line segment at a specific point more efficiently?

This is a problem that I have often encountered, and I am looking for a more effective way to solve it. Take a look at these photos:

enter image description hereenter image description here

Suppose you want to find the shortest distance from a red dot to a line segment n . Suppose you know only the start / end point (x, y) of the segments and the point. Now this can be done in O (n), where n are line segments, checking each distance from a point to a line segment. This IMO is inefficient, because in the worst case, there should be n-1 remote checks until the right one is found.

n = 1000 f.e. ( ), , , , , Vincenty's.

:

  • ?
  • ?
  • ?

, , , - O (n). , ?

: , / "" - , , . -, O (m), m < .

+4
1

, , . , .

, . , ( , ), . , Quadtree.

, , , . , ( ) .

+3

Source: https://habr.com/ru/post/1546373/


All Articles