You want to double check my work here (though some use of rand() and Tk could make quick work of testing visually). I'm assuming X1 < X2 , Y1 < Y2
my @box = ( { name => "Box 1", x1 => 0, y1 => 0, x2 => 320, y2 => 100 }, { name => "Box 2", x1 => 100, y1 => 10, x2 => 510, y2 => 500 }, { name => "Box 3", x1 => 20, y1 => 300, x2 => 120, y2 => 600 }, { name => "Box 4", x1 => 300, y1 => 301, x2 => 310, y2 => 600 }, ); sub bounding_box { my @box = sort { $a->{x1} <=> $b->{x1} } @_; # Sort on X axis for ( my $i = 0 ; $i < $#box ; $i++ ) { for ( my $j = $i + 1 ; $j < @box ; $j++ ) { warn "Checking $box[$i]->{name} against $box[$j]->{name}\n +"; if ( $box[$i]->{x2} > $box[$j]->{x1} ) { if ( $box[$i]->{y2} > $box[$j]->{y1} && $box[$i]->{y1} < $box[$j]->{y2} ) { warn " $box[$i]->{name} overlaps $box[$j]->{name}\ +n"; # Do something here } else { warn " $box[$i]->{name} doesn't overlap $box[$j]->{na +me}\n"; } } else { last; } } } }
update My spaceship <=> was half missing. Whoops.

-Lee
"To be civilized is to deny one's nature."

In reply to Re: Detecting control placement constraints in dialog resources - rectangle overlap checking by shotgunefx
in thread Detecting control placement constraints in dialog resources - rectangle overlap checking by GrandFather

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.