Re: Algorithm to identify area in common?



"No Such Luck" <no_suchluck@xxxxxxxxxxx> writes:

> > > Suppose I have two rectangles existing in space (memory), and these
> two
> >> rectangles are represented by their bounding box coorinates: top
> left
> >> corner (x1, y1), bottom right corner (x2, y2). Is there an algorithm
> >> that, when given the bounding box cooridinates of two of these
> >> rectangles, will return the union of the areas of the rectangles, in
> >> square units?
> >

If we have a lower left corner and an upper right corner, using the
normal Cartesian coordinate system (x increasing to the right, y
increasing up), and the rectangles are { (ax1,ay1) , (ax2,ay2) }
and { (bx1,by1) , (bx2,by2) }, then

The lower left corner of the intersection box is

( MAX( ax1, bx1 ), MAX( ay1, by1 ) )

Similarly the upper right corner of the intersection box is

( MIN( ax2, bx2 ), MIN( ay2, by2 ) )

I expect you can make suitable adjustments for the coordinate
system you're using.

.



Relevant Pages

  • Re: fmincon
    ... The rectangles are alligned to axes so the code of calculating the intersection is o'k i guess. ... Excuse me for maybe stupid question: -A as sign to empty intersection is given to implement say constraint c< 0? ... As far as I understood from Alex, ...
    (comp.soft-sys.matlab)
  • Re: fmincon
    ... The rectangles are alligned to axes so the code of calculating the intersection is o'k i guess. ... Excuse me for maybe stupid question: -A as sign to empty intersection is given to implement say constraint c< 0? ... You can transform it into a equivalent linear constraints, however the equivalent number of linear equations should be much larger. ...
    (comp.soft-sys.matlab)
  • Re: Problem with "IntersectsWith" function in GDI+
    ... exercise to do your own intersection test with whatever boundary rules you ... Doug Forster ... strange problem w.r.t IntersectsWith function which is used to determine ... whether two given rectangles intersect with each other not. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Find the intersection of two rectangles
    ... Unless the rectangles are axis-aligned, ... the general case of Convex Polygon Intersection. ... And the intersection is empty unless ...
    (comp.lang.c)
  • Re: simple measure theory question
    ... union, intersection, difference, symmetric difference and complement. ... or does disjoint mean measure zero intersection? ... rectangles can be any as you have described ... be elementary for being the intersection of two elementary sets. ...
    (sci.math)