Distance transform

Manhattan distance formula: |x1 - x2| + |y1 - y2|

Distance transform

Manhattan distance formula: |x1 - x2| + |y1 - y2|

Manhattan distance, also known as City block distance, measures the distance between two points in a grid-based path. It is calculated as the sum of the absolute differences of their Cartesian coordinates.

Example

If point A is at (3, 4) and point B is at (1, 1), the Manhattan distance is |3 - 1| + |4 - 1| = 2 + 3 = 5.

Understanding Manhattan distance is crucial in grid-based pathfinding algorithms, such as those used in urban planning and video game navigation.

Related concepts

One email a day: 5 concepts + the 5 stories that matter →

Swipe through 100 ML concepts daily

Open TickerNews