[Math] Knowing only the coordinates of the North-East and South-West corners of a rectangle, how to check if a point is inside a rectangle

computational geometrygeometry

This is similar to this question. What's different is that only the coordinates of the North-East and South-West (or North-West and South-East) corners are known.

My question is, can you directly determine if a point lies inside the rectangle without finding the coordinates of the other 2 corners?

If finding the other 2 coordinates is necessary, what would be a good approach for finding them?

Best Answer

I assume that, as in the question you linked to, the rectangle can have any orientation and is not limited to horizontal/vertical sides.

There are infinitely many rectangles that have two given points as opposite vertices: a third vertex can be any point on the circle that has those two points as the ends of a diameter. A point outside that circle will be in none of the rectangles, while a point on the line segment between the two points will be in all the rectangles. All other points inside the circle but not on the line segment will be in some rectangles and not in others.

Therefore, there is no way to " directly determine if a point lies inside the rectangle without finding the coordinates of the other 2 corners" for those points. Also, there is no way to find the other two corners without additional information.

enter image description here

Related Question