Determine if a point lies in a quadrangle

404 Views Asked by At

I have a quadrangle which sides consist of parts of rays, and I only know the coordinates of two points on each ray.

I need to determine if a point $(x,y)$ lies in such quadrangle.

In this picture, I painted the sides of the quadrangle red in case you don't understand about what quadrangle I'm talking.

1

There are 1 best solutions below

0
On

Let $A(x_a, y_a), B(x_b, y_b), C(x_c, y_c)$ and $D(x_d, y_d)$ form the quadrilateral $ABCD$ with area $S$ and let $P$ be the point you've chosen.

Calculate the areas of the triangles $\triangle PAB, \triangle PBC, \triangle PCD$ and $\triangle PDA$, for instance, with the shoelace formula. Let their sum be $S'$. Then

\begin{align*} S'=S&\implies P\text{ lies inside }ABCD\\ S'>S&\implies P\text{ lies outside } ABCD \end{align*}