https://cp-algorithms.com/geometry/point-in-convex-polygon.html
In above link, the code for checking whether a point is inside a convex polygon is flawed. I tested on some examples, it gave wrong answer.
Can someone point out the mistake and thus request the author to correct it!
This blog was actually helpful.
I'm sorry but I upvoted you
Could you provide the test you were testing with?
One of the tests is:
Polygon points: (1,1) (6,2) (2,5)
Query point: (0,0)
In the function
prepare
, the code moves the polygon by-points[0]
, and in the codepointInConvexPolygon
, it doesn't move the point being queries. So I think if you wanna check the point (0, 0), you're supposed to query(0, 0)-(1, 1)=(-1, -1)
. And querying(-1, -1)
does return 0. I think it's just a bad documentation / weird formating of the function on their part.