5
$\begingroup$

Given the coordinates of two rectangles on a coordinate plane, what would be the easiest way to find the coordinates of the intersecting rectangle of the two?

I am trying to do this programatically.

  • 1
    Are the corners of the rectangles on the grid points? (Otherwise, the intersection won't necessarily be a rectangle.)2010-10-20
  • 1
    @Mike: If the rectangles intersect, their intersection will form a new rectangle (possibly 1-dimensional i.e. line) as long as one of the lines in the first rect. is parallel to a line in the 2nd rect. I don't see how the coordinates of the corners influence this in any way.2010-10-20
  • 0
    @Jericson: Right. I was trying to figure out a way to make the problem well-defined (i.e., guarantee that you actually get a rectangle for the intersection). We'll see what the OP says.2010-10-20

3 Answers 3