0

I have a quadrilateral (not an exact rectangle or parallelogram) and can determine whether or not a point is in the box by using solutions found here:

How to check if a point is inside a rectangle?

I have a series of points and I want to mathematically determine where those points are within the quadrilateral (different divisions).

If i divide the quadrilateral in thirds (not exactly) can i determine if a point is within different divisions of the quadrilateral without having to use the same methods as found in the link above and just apply it to all the different divisions?

The points cannot be changed.

paulST
  • 11

1 Answers1

1

If your box is a parallelegram (parallelepiped in 3 dimensions - it isn't clear to me which you mean by "box", but I will assume 2 dimensions in the rest), then a simple change of coordinates can convert it into a rectangle in coordinate space with one corner at the origin, and its adjacent edges lying on the positive axes. If your divisions were parallel to the sides, then they become horizontal and/or vertical lines, and testing where the point lies becomes nothing more than finding $n, m$ such that $x_n \le x < x_{n+1}, y_m \le y \le y_{m+1}$ for some fixed sequences $x_n, y_m$ defining your divisions. If your divisions are equally spaced, the particular division can be found by

For example. if your box has corners $(-1,-1), (3, -2), (2,3), (6, 2)$, we can add $\begin{bmatrix}1\\1\end{bmatrix}$ to bring the first point to the origin. The other three points become $(4, -1), (3, 4), (7,3)$ (note that the sum of the first two is the third - this confirms that the box is a parallelegram). The change of coordinate function will be $$\begin{bmatrix}x\\y\end{bmatrix} = \begin{bmatrix}4&-3\\-1&4\end{bmatrix}\begin{bmatrix}u\\v\end{bmatrix} - \begin{bmatrix}1\\1\end{bmatrix}$$ Where $x, y$ are the original coordinates and $u, v$ are the new ones, so we need to solve it: $$\begin{bmatrix}u\\v\end{bmatrix} = \frac{1}{13}\begin{bmatrix}4&3\\1&4\end{bmatrix}\left(\begin{bmatrix}x\\y\end{bmatrix} + \begin{bmatrix}1\\1\end{bmatrix}\right)$$

Your box is converted into the unit square. So if you want to divide each side of your box into thirds (so nine smaller parallelegrams for divisions), then the answer of which a particular point $(x,y)$ lies in is just matter of finding $(u,v)$ as above, and deciding whether $u \in [0,1/3), [1/3,2/3],$ or $(2/3,1]$ and similarly for $v$.

Paul Sinclair
  • 43,643