if (RectA.Left < RectB.Right && RectA.Right > RectB.Left &&
RectA.Top > RectB.Bottom && RectA.Bottom < RectB.Top )
or, using Cartesian coordinates
(With X1 being left coord, X2 being right coord, increasing from left to right and Y1 being Top coord, and Y2 being Bottom coord, increasing from bottom to top -- if this is not how your coordinate system [e.g. most computers have the Y direction reversed], swap the comparisons below) ...
if (RectA.X1 < RectB.X2 && RectA.X2 > RectB.X1 &&
RectA.Y1 > RectB.Y2 && RectA.Y2 < RectB.Y1)
Say you have Rect A, and Rect B.
Proof is by contradiction. Any one of four conditions guarantees that no overlap can exist:
- Cond1. If A's left edge is to the right of the B's right edge,
- then A is Totally to right Of B
- Cond2. If A's right edge is to the left of the B's left edge,
- then A is Totally to left Of B
- Cond3. If A's top edge is below B's bottom edge,
- then A is Totally below B
- Cond4. If A's bottom edge is above B's top edge,
- then A is Totally above B
So condition for Non-Overlap is
NON-Overlap => Cond1 Or Cond2 Or Cond3 Or Cond4
Therefore, a sufficient condition for Overlap is the opposite.
Overlap => NOT (Cond1 Or Cond2 Or Cond3 Or Cond4)
De Morgan's law says
Not (A or B or C or D)
is the same as Not A And Not B And Not C And Not D
so using De Morgan, we have
Not Cond1 And Not Cond2 And Not Cond3 And Not Cond4
This is equivalent to:
- A's Left Edge to left of B's right edge, [
RectA.Left < RectB.Right
], and
- A's right edge to right of B's left edge, [
RectA.Right > RectB.Left
], and
- A's top above B's bottom, [
RectA.Top > RectB.Bottom
], and
- A's bottom below B's Top [
RectA.Bottom < RectB.Top
]
Note 1: It is fairly obvious this same principle can be extended to any number of dimensions.
Note 2: It should also be fairly obvious to count overlaps of just one pixel, change the <
and/or the >
on that boundary to a <=
or a >=
.
Note 3: This answer, when utilizing Cartesian coordinates (X, Y) is based on standard algebraic Cartesian coordinates (x increases left to right, and Y increases bottom to top). Obviously, where a computer system might mechanize screen coordinates differently, (e.g., increasing Y from top to bottom, or X From right to left), the syntax will need to be adjusted accordingly/
This site seems to have a script that will do what you want:
http://megastep.org/makeself/
From the site:
makeself.sh is a small shell script that generates a self-extractable tar.gz archive from a directory. The resulting file appears as a shell script (many of those have a .run suffix), and can be launched as is. The archive will then uncompress itself to a temporary directory and an optional arbitrary command will be executed (for example an installation script). This is pretty similar to archives generated with WinZip Self-Extractor in the Windows world. Makeself archives also include checksums for integrity self-validation (CRC and/or MD5 checksums).
See the comment about v2.1.5 supporting encryption through gpg.
I think it's called a shell archive, the original being written by James Gosling (inventor of Java).
http://blogs.oracle.com/jag/entry/shar_a_blast_from_the
Best Answer
I'm assuming you have a directed graph which you layout with dot.
I don't think there's a magic switch to prevent overlapping edges. Graphviz tries to do that out of the box.
Some suggestions that may help, depending on the graph: