Skip to main content
3 of 3
summarized points the OP seems to be looking for
Zev Chonoles
  • 6.8k
  • 4
  • 54
  • 92

I imagine the only useful way of interpreting a rectangle with negative w and/or h should just be as a rectangle with positive width and height, only starting at a different point (it's lower left vertex, it seems?).

With either union or intersection as the operation, you're going to run into a couple of problems if you want the structure to be a group. The only possible choice for the identity under intersection is the entire plane (which, if you are parametrizing the rectangles in the plane using (x,y,w,h), would require you to allow x=y= $-\infty$, w,h=$\infty$), and the only possible choice for the identity under union is an "empty" rectangle (i.e., w=h=0, though you'll also have the problem that there is one of these at each x and y). Of course, given any rectangle which is not the entire plane, you can't take an intersection of it with something and get the entire plane, and similarly, given any rectangle which is non-empty, you can't take the union of it with something and get an empty rectangle - that is, there won't be inverses. However, as you guessed in the title, you still do get a commutative monoid.

You can make a group (and even ring) structure, similar to what you are describing, out of the collection of all subsets of the plane (or any set), as described here, but you'd have to give up your restriction to only rectangles if you want to use this one, because the operation used is the symmetric difference.

EDIT: This is to summarize the things you seem to be looking for:

  • The set of rectangles in the plane, under the operation of intersection, makes a commutative monoid if you allow for the "infinite rectangle" consisting of the entire plane.
  • Unfortunately, under union (as you defined it for rectangles - least rectangle containing both), there is in fact no identity, because given any two distinct "empty" rectangles, let's say the ones at (a,b) and (c,d), their "union" would be the rectangle with opposite corners at (a,b) and (c,d) and so is non-empty, so neither of them can be an identity. Thus, the set of rectangles in the plane, under the operation of "union", is only a commutative semigroup.
  • The set of rectangles is not closed under taking symmetric difference or the usual union.

That describes the situation with the main set-theoretic operations, though you may be able to construct another operation on rectangles using some combination of addition and multiplication on the parameters (x,y,w,h) which makes a stronger structure.

Zev Chonoles
  • 6.8k
  • 4
  • 54
  • 92