0
$\begingroup$

Suppose $P_1=(x_1,y_1)$, $P_2=(x_2,y_2)$ are two points.

Also suppose that we have a rectangle which we just know the value of its sides $a$ and $b$.

I am looking for some kind of formulation which can show whether $P_1$ and $P_2$ are inside of rectangle or not.

  • 0
    If the two points are in the same rectangle (wherever that rectangle may be) then $\lfloor\frac{x_1}{a}\rfloor = \lfloor\frac{x_2}{a}\rfloor \text{ and } \lfloor\frac{y_1}{b}\rfloor = \lfloor\frac{y_2}{b}\rfloor. $2012-03-21

1 Answers 1

1

Without knowing the position of the rectangle, it is impossible to tell whether any particular point lies inside of it. The most one can say (as the commenters pointed out), is that the conditions $|x_1-x_2|\le a \quad \text{and } \ |y_1-y_2|\le b$ are necessary for the two points to belong to the same (axes-aligned) rectangle $a\times b$. It is also sufficient if you are allowed to move the rectangle.