Euclidean vs Chebyshev vs Manhattan Distance

I have learned new things while trying to solve programming puzzles. One of these is the calculation of distance.

There are many metrics to calculate a distance between 2 points p (x1, y1) and q (x2, y2) in xy-plane. We can count Euclidean distance, or Chebyshev distance or manhattan distance, etc. Each one is different from the others.

To simplify the idea and to illustrate these 3 metrics, I have drawn 3 images as shown below.

The first one is Euclidean distance. The distance can be defined as a straight line between 2 points. The formula to calculate this has been shown in the image.

In Chebyshev distance, all 8 adjacent cells from the given point can be reached by one unit.

 The last one is also known as L1 distance. The distance between two points is the sum of the (absolute) differences of their coordinates. E.g. it only costs 1 unit for a straight move, but 2 if one wants to take a crossed move.

Applications of these in Chess:

In chess, the distance between squares on the chessboard for rooks is measured in Manhattan distance; kings and queens use Chebyshev distance, andbishops use the Manhattan distance (between squares of the same color) on the chessboard rotated 45 degrees, i.e., with its diagonals as coordinate axes. To reach from one square to another, only kings require the number of moves equal to the distance; rooks, queens and bishops require one or two moves (on an empty board, and assuming that the move is possible at all in the bishop’s case). (Wikipedia)

Advertisements

6 thoughts on “Euclidean vs Chebyshev vs Manhattan Distance

  1. Pingback: Returns clustering with K-means algorithm | QuantDare
  2. Pingback: quantDare

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s