in reply to Re^2: Checking if squares intersect
in thread Checking if squares intersect

x4 is absent, so there's surely an error

Adjacent squares don't intersect, so
< should be <=
> should be >=

You didn't indicate whether lower "y" values are located higher (that's what you used) or lower (cartesian), so I can't verify the if you are comparing the "y"s properly.

Replies are listed 'Best First'.
Re^4: Checking if squares intersect
by Anonymous Monk on Oct 14, 2009 at 20:51 UTC
    But wouldn't the squares intersect if I changed to < to <= ?

    Example, if x2 <= x3 then the statement is true if x2 intersects with x3 since x2 is the lower right corner and x3 is the upper left corner.

    And yes, the x4 is missing, it was a typo.
      No. Adjacent squares don't intersect.
      x1 x2=x3 x4 +---------+ y1 | +---------+ y3 | | | | | | | | | +---------+ | y2 +---------+ y4
        If two lines can intersect in a point, can't two squares intersect in a point or a line?

        -QM
        --
        Quantum Mechanics: The dreams stuff is made of

        Adjacent squares would be side by side, in the above the edge of each square intersect.
        So x2=x3 means that the edge of one square intersects with the edge of the other...