Answer the question
In order to leave comments, you need to log in
What is the algorithm for determining the nearest segment of the path to a point?
Given a path on the map as an ordered set of points.
There is a point that moves along this path, but with some error.
It is necessary to determine the nearest section of the path (segment, edge) to a given point.
The task at first seemed simple, but then pitfalls surfaced. I think that there is already an existing algorithm, but which one? Voronoi diagrams? Delaunay triangulation?
Answer the question
In order to leave comments, you need to log in
Seems to have found the answer.
You need to use a BSP tree https://en.wikipedia.org/wiki/Binary_space_partitioning
stackoverflow.com/questions/3423852/algorithm-to-f...
and more options to choose from:
https://gist.github.com/ mbostock/8027637
stackoverflow.com/questions/18900642/get-point-on-...
Find distances to all points, adjacent segments to the closest point and a perpendicular to one of them. If one exists, the answer is the length of this perpendicular, otherwise, the distance to the nearest point
normal to a line (or projection of a point onto a line): the line segment from a point to the intersection with a line at an angle of 90 degrees to that line.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question