Kaupunkiblokkietäisyys
Kaupunkiblokkietäisyys, often translated as "city block distance" or "Manhattan distance," is a metric for measuring the distance between two points in a grid-based system. Imagine a city laid out in a rectangular grid of streets. The kaupunkiblokkietäisyys between two points is the total distance you would have to travel along these streets to get from one point to the other, without cutting across blocks. Mathematically, if you have two points with coordinates (x1, y1) and (x2, y2), the kaupunkiblokkietäisyys is calculated as the absolute difference of their x-coordinates plus the absolute difference of their y-coordinates: |x1 - x2| + |y1 - y2|. This is in contrast to the Euclidean distance, which is the straight-line "as the crow flies" distance. Kaupunkiblokkietäisyys is frequently used in urban planning, navigation systems where travel is restricted to roads, and in certain computer science algorithms, such as those related to image processing and pathfinding on grids. Its simplicity and intuitive nature in grid environments make it a practical choice for many applications.