geometry - How to Find the Minimum Taxicab/Manhattan Distance Between Two Parallel Rectangles? -
Looking at the coordinates of the top left corner of both rectangulars, and the coordinates of the lower right corner of both rectangles, and rectangular one- Others are parallel, as well as the X and Y axis, how do the minimum taxicab / Manhattan distance get between two rectangles? It comes down to classifying the relationship between the two rectangles. I think that they do not pierce each other, in that case there are only two situations: In the first case, the distance between Manhattan between two opposing corners (TL-BR, TR-BL, BR-TL, BL-TR) In the second case you get the X coordinates Switch to difference or Y take the difference in coordination rectangular side depending on the situation (BT, LR, RL, TB) is all tested with some very easily if or case statement.
Comments
Post a Comment