Check whatever a vector is pointing toward the interior of a closed polygon

34 Views Asked by At

Let's $(P)$ be a closed polygon with vertices $P_k, k=0,\cdots n$(modulo $n$). How to check if $\vec{J}=\vec{P_kP_{k-1}}+\vec{P_kP_{k+1}}$ points towards the exterior (resp. interior) of $(P)$.

1

There are 1 best solutions below

4
On BEST ANSWER

With these elements of information that you hadn't given, here is an answer.

Therefore, you have a closed polygon $(P)$ with vertices $P_k, k=0,\cdots n$ (modulo $n$). If $(P)$ is traversed in the direct sense (trigonometric orientation), $(P)$ will be situated "on the left hand side" by a vehicule following the border.

This said, it is easy to see that $J=\vec{P_kP_{k-1}}+\vec{P_kP_{k+1}}$ will point towards the exterior (resp. interior) of $(P)$ if $P_k$ is a point of concavity (resp. convexity) of polygon $(P)$.

As you have remarked, testing whether a point is a point of concavity (resp. convexity) of the border $\partial (P)$ is done by computing the nature of orientation change, which is easy to compute without dealing with angles through the sign of the determinant

$$\det(\vec{P_{k-1}P_k},\vec{P_kP_{k+1}}) ;$$

if it is $<0$ (resp. $>0$), it is a point of concavity (resp. convexity).