0

Is there simplified version of the approach for deciding if a point lies into a parallelogram?

Parallelogram can be defined by specifying of one vertex and two radius vectors.

Seems the formula from linked answer consists of a sum of cross products and whole formula is based on area calculation. The area of parallelogram is just one single cross product. How can one decide if the point is inside of parallelogram?

2 Answers2

2

Assuming a vertex of the involved parallelogram lies at the origin (if this is not the case, it is enough to apply a suitable translation) the set of points belonging to the interior of the parallelogram is of the form $\mu\vec{a}+\lambda\vec{b}$ with $\mu,\lambda\in(0,1)$ and $\vec{a},\vec{b}$ being two linearly independent elements of $\mathbb{R}^2$. If we have a generic $\vec{p}$ we have a unique way for writing $\vec{p}$ as $\mu \vec{a}+\lambda\vec{b}$ and we just have to check if $\mu,\lambda$ both belong to $(0,1)$ or not. For instance, let us check if $(2,2)$ belongs to the interior of the parallelogram generated by $(4,1)$ and $(1,1)$. $(2,2)=\mu(4,1)+\lambda(1,1)$ is equivalent to $4\mu+\lambda=2=\mu+\lambda$ and to $\mu=0,\lambda=2$, so $(2,2)$ does not belong to the interior of the wanted parallelogram.

Jack D'Aurizio
  • 353,855
2

Let $ABCD$ be our parallelogram, $A$ the origin of our coordinate system. Then, the vectors $\overrightarrow{AB}=a=(a_x,a_y)$ and $\overrightarrow{AD}=b=(b_x,b_y)$ define the parallelogram.
Then, the vectors $a'=(-a_y,a_x)$ and $b'=(-b_y,b_x)$ are orthogonal to $a$ and $b$. There's no need to normalise them, but we need to make sure that they have the correct orientation ($\langle \cdot{,}\cdot\rangle$ is the scalar product, of course):

$$ a''=\operatorname{sign}(\langle a',b\rangle)\,a',\quad b''=\operatorname{sign}(\langle a,b'\rangle)\,b' $$

Now, all $p$ satisfying

$$ 0 \le \langle a'',p \rangle \le \langle a'',b \rangle \tag1 $$

lie in the area between the parallel line segments $AB$ and $CD$, and the $p$ satisfying

$$ 0 \le \langle b'',p \rangle \le \langle a,b'' \rangle \tag2 $$

lie in the area between the line segments $AD$ and $BC$. Both (1) and (2) together are the criterion for "$p$ is inside the parallelogram". If your "inside" means "strictly inside" (not on the sides of the parallelogram), the inequalities in (1) and (2) have to be strict, naturally.