# DistanceFrom Problem

Last month, Tsung-Yuan Liu reported that he was getting inconsistent results with DistanceFrom. DistanceFrom A->B was not the same as DistanceFrom B->A.

If you create two identical squares seperated by a gap,
DistanceFrom A->B = DistanceFrom B->A = the value of the gap

If you change one of the squares to a rectangle by reducing the hieght and maintain the gap, as long as the tops or the bottoms are aligned, the above relationship still holds.

Maintaining the gap, move the smaller rectangle (shape A), so that it’s top is below the top of the larger shape (shape B) and it’s bottom is above the bottom of the larger shape, DistanceFrom A->B is still the size of the gap, but DistanceFrom B->A is now larger than the gap. The width of the shapes has no effect on DistanceFrom and as long as the gap is maintained, the width of either shape can be reduced to almost nil and the values for DistanceFrom will not change. The maximum difference for a specific pair of shapes and a given gap is obtained by aligning the shapes vertically along their center lines.

So what does this larger number represent?  Take the difference in the hieght of the tops of the two shapes (or the bottoms if that value is smaller) add the square of the gap and take the square root. This will give yo the larger number. In other words, if shape  A is on the left and it’s center is higher, the larger DistanceFrom value is the distance from the top right corner of shape A to the top left corner of shape B.

So the work around to minimize this problem is to do both calculations and use the smaller value.

Yoda has reported a similar effect with a trapezoid and a circle, but I have been unable to determine what the larger value represents. The smaller one does appear to be the shortest distance.
http://www.mster.co.jp/visiosquare/cgi-bin/cbbs/file/DistanceFrom.gif