S
S
Sergey Khlopov2020-01-02 19:22:38
Algorithms
Sergey Khlopov, 2020-01-02 19:22:38

How to implement the method of belonging to a point to a polygon?

Hello, please tell me the algorithm of actions when implementing the method for determining a point to a polygon - Accounting for the number of revolutions . Thank you in advance for your response.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
eRKa, 2020-01-03
@kttotto

This is a standard problem of geodesy for the occurrence of a point in a polygon, it is solved by skew multiplication of vectors.
In fact, all segments of the polygon are moved and it looks on which side of the segment the point lies. You count the number of all cases when it lies to the right of the segment (that is, it crosses when turning), you filter out all the segments that lie above or below the point. If the number on the right is even or zero, then the point is not included in the polygon, if it is odd, then it lies inside the polygon.
The code solves in five lines.
PS: found my answer two years ago)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question