Distance Formulas
Euclidean Distance (2D):
In two-dimensional Cartesian coordinates (x1, y1) and (x2, y2), the Euclidean distance (also known as the straight-line distance or Pythagorean distance) between these two points is given by the Pythagorean theorem:
Distance = √((x2 - x1)^2 + (y2 - y1)^2)
Euclidean Distance (3D):
In three-dimensional Cartesian coordinates (x1, y1, z1) and (x2, y2, z2), the Euclidean distance between these two points is similar to the 2D formula, but extended to three dimensions:
Distance = √((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)
Manhattan Distance (City Block Distance):
The Manhattan distance between two points in Cartesian coordinates is the sum of the absolute differences of their coordinates. It's called "Manhattan" distance because it's akin to measuring distance by navigating city blocks.
Distance = |x2 - x1| + |y2 - y1|
Minkowski Distance:
The Minkowski distance is a generalized distance metric that includes both Euclidean distance and Manhattan distance as special cases. It's defined as:
Distance = (Σ(|xi - yi|^p))^1/p, where i ranges over the dimensions.
When p = 2, it becomes the Euclidean distance, and when p = 1, it becomes the Manhattan distance.
Chebyshev Distance:
The Chebyshev distance (or chessboard distance) between two points in Cartesian coordinates is the maximum absolute difference of their coordinates:
Distance = max(|x2 - x1|, |y2 - y1|)