Determining if a point is on the road

If I have a polyline that describes the road, and I know the width of the road in all parts, is there an algorithm I can use to determine if a point is on the road? I'm not quite sure how to do this, since the string itself is 1px wide.

thanks,

Jeff

+3
source share
2 answers

Find the minimum distance from a point to a line (this will be a vector perpendicular to the line). The actual calculation, where P0 is the first point of the road segment, v is the vector of the road segment, w is the vector from P0 to the point in question. You will need to iterate over each edge in the polyline. If the distance is less than the width of this segment, then this is an "on" road.

d = |v x w| / |v|

Angles can be complex depending on whether you are processing them rounded (constant radius) or angular.

+2
source

, , + / , , . width = 1, , y-1 (point.y) x line_segment.x1 line_segment.x2

+2

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


All Articles