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:

  • The second rectangle is first fully located in one of the four corners of the rectangle
  • All other conditions < / Ol>

    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

    Popular posts from this blog

    mysql - BLOB/TEXT column 'value' used in key specification without a key length -

    c# - Using Vici cool Storage with monodroid -

    python - referencing a variable in another function? -