Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Sorting hashes...

by xdg (Monsignor)
on May 10, 2007 at 19:22 UTC ( [id://614742]=note: print w/replies, xml ) Need Help??


in reply to Sorting hashes...

A couple thoughts:

  • You might have rectangles with the same area, so your hash should key on the coordinates, not the area. E.g. $NetAreaHash{$MinX,$MinY,$MaxX,$MaxY} = $Area (the commas in the hash key combine to make a unique key).

  • For checking overlap, if any vertex of rectangle A is within rectangle B then they overlap. If no vertex of A is within B, B might still be entirely contained within A, so check one vertex of B to see if it's within A.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^2: Sorting hashes...
by husker (Chaplain) on May 11, 2007 at 21:23 UTC
    For checking overlap, if any vertex of rectangle A is within rectangle B then they overlap. If no vertex of A is within B, B might still be entirely contained within A, so check one vertex of B to see if it's within A.

    Actually, two rectangles could intersect without any vertex of either box lying inside the other. Picture two rectangles, perpendicular to each other, arranged as a cross.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://614742]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found