K
K
Kooper_pro2018-03-17 18:18:19
Algorithms
Kooper_pro, 2018-03-17 18:18:19

How to find out if a point lies in a given polygon?

There is a picture, it has n number of polygons (mostly 4-angle), they do not intersect. So how do you know to which polygon an arbitrarily introduced current belongs?
5aad315cd4b10569980200.jpeg
What mathematical algorithm should be used?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
X
xmoonlight, 2018-03-17
@Kooper_pro

So I say that the ways to solve the problem work faster than the tools.
I suggest a simple way: use the polygon color fill in memory and check the color of the point in the desired coordinates)
And it will work quickly (natively - EVERYWHERE!) And it will definitely work!)
If you need to quickly and periodically check (mouse-move, for example) - make a map: an image with areas filled with different colors (somewhere in memory).
Then, we take the desired coordinates (the current coordinates of the "mouse" cursor, for example) the color of the map image pixel (from memory) and look at the created list based on the number of necessary (for monitoring) zones: which zone/segment it (pixel with desired coordinates) belongs.
5aad3e35aa45e994005779.png

T
twobomb, 2018-03-17
@twobomb

Algorithm for determining if a point hits the contour on o ...
Here , I redid the function in javascript , you can see it visually.

S
Stalker_RED, 2018-03-17
@Stalker_RED

The problem of whether a point belongs to a polygon

R
Ruslan., 2018-03-17
@LaRN

Algorithms are detailed here
https://habrahabr.ru/post/301102/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question