I'd like to know when a point is contained in a convex $n-$polygon.I find one question here, but it's different from my problem.
2026-03-29 20:34:54.1774816494
On
Point inside a convex polygon
1.6k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
1
On
There's a rather easy way: Let's assume your point is $P_0=(x_0,y_0)$, and your polygon is given as a sequence of points $P_i=(x_i,y_i)$ for $i=1,\ldots,n$, and let's assume $P_{n+1}=P_1$. First, you determine the indices $i$ where $P_i, P_{i+1}$ lie on different sides of the horizontal line through $P_0$, i.e. $(y_i-y_0)(y_0-y_{i+1})\ge0$. There must be two such indices. Then, you determine the abscissas of the intersection of $P_iP_{i+1}$ with $y=y_0$. If $x_0$ lies between them, your point is inside the polygon, in all other cases (meaning that there aren't two intersection points, or $x_0$ isn't between them), it's outside.
Let $A_1A_2...A_n$ be our convex polygon, $A_{n+1}\equiv A_1$ and $P$ be a point in the plain of this polygon.
Now, if $$\sum_{k=1}^n\measuredangle A_kPA_{k+1}=360^{\circ}$$ then $P$ placed inside our polygon.
If $$\sum_{k=1}^n\measuredangle A_kPA_{k+1}\neq360^{\circ}$$ then this is not so.