Point in polygon | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Point in polygon

How to find whether a point lies inside the polygon only using the coordinates of the point and the coordinates of the points of polygon as an array?

11th Sep 2019, 4:53 PM
Joyson John
Joyson John - avatar
2 Answers
+ 2
You need an „even-odd rule“ algorithm, to check whether a point is inside a polygon. The idea is to test how many times a ray intersects the edges of the polygon. This ray starts at the test point and can go in any direction. If the number of intersections is odd, the point is located inside the polygon, otherwise it is outside the polygon. https://code.sololearn.com/WEANHkGPRytN/?ref=app
11th Sep 2019, 6:53 PM
Michael
Michael - avatar
0
Thank you so much Michael.
12th Sep 2019, 5:01 AM
Joyson John
Joyson John - avatar