Distance
calculator.
Measure the distance between two points, in 2D or 3D, or between two places on Earth.
- Manhattan
- 7
- Chebyshev
- 4
- Minkowski, p = 3
- 4.4979
Walking along the grid takes 7, and the straight line is 5. The largest single difference is 4, the fewest moves for a chess king in a grid.
The right triangle behind it
Drag a point to move itA straight line of length 5 from (1, 2) to (4, 6). The dashed legs are 3 across and 4 up or down, and together they make the Manhattan distance, 7.
Working
- 1Differences: second point minus firstΔx = 4 − 1 = 3Δy = 6 − 2 = 4
- 2Square them, add, and take the rootd = √(3² + 4²)d = √25 = 5
- 3Manhattan: add the sizes of the differences|3| + |4| = 7
- 4Chebyshev: the largest of themmax(|3|, |4|) = 4
- 5Minkowski, with p = 3(Σ|Δ|3)13= 4.4979
- 6Check: go through the midpoint, and the two parts make d2.5 and 2.5, which add to 5
The same two points as p grows
| p | Distance | Also called |
|---|---|---|
| 1 | 7 | Manhattan |
| 1.5 | 5.5843 | Between the others |
| 2 | 5 | Straight line |
| 3 | 4.4979 | Between the others |
| 10 | 4.022 | Between the others |
| ∞ | 4 | Chebyshev |
Measure a list
Type or paste one row per pair of points.
| # | x₁ | y₁ | x₂ | y₂ |
|---|---|---|---|---|
| 1 | ||||
| 2 | ||||
| 3 |
Each pair
| Points | Straight | Manhattan | Chebyshev |
|---|---|---|---|
| (0, 0) to (3, 4) | 5Manhattan 7Chebyshev 4 | 7 | 4 |
| (1, 2) to (4, 6) | 5Manhattan 7Chebyshev 4 | 7 | 4 |
| (−3, −1) to (2, 3) | √41 ≈ 6.4031Manhattan 9Chebyshev 5 | 9 | 5 |
How it's worked out
The straight-line distance is the Pythagorean theorem in coordinates. The differences in x and y are the legs of a right triangle, and the distance is its long side.
In three dimensions, one more squared term joins in, and the distance becomes the diagonal of a box with the two points at opposite corners. When every coordinate is whole, the tool also pulls square factors out of the root, which is called simplest radical form.
Other measures suit other jobs. Manhattan distance adds the sizes of the differences, as on a street grid. Chebyshev distance is just the largest one. Minkowski distance holds both as special cases, with an order that you choose.
Places on Earth need a different method, since the ground curves. The haversine formula finds the angle at Earth's center between two points, with for latitude and for longitude. Multiplying by the radius gives the great-circle distance. This uses the mean radius of 6,371.0088 km from the GRS 80 reference system.
As a check, the tool also finds the same angle by the spherical law of cosines. The haversine form holds up better on short legs, where the other route loses accuracy to rounding.
Worked examples
Kim compares two routes across town
On a grid in kilometers, Kim is at (−3, −1) and the drop-off is at (2, 3). The differences are 5 and 4, so the squares add to 41.
That is about 6.4 km in a straight line, and 9 km if she has to follow the streets. The longest single leg of the grid route is 5 km.
Noah checks if a long rod fits his room
His room is 5 m long, 4 m wide and 3 m high. The longest straight line runs from a floor corner to the far ceiling corner, the box's diagonal.
The squares add to 50, so the distance is 5√2, about 7.07 m. A rod shorter than that fits if he can get it in the door. Walking the edges instead would take 12 m.
Ada works out her flight from New York to London
JFK sits at 40.6413° N, 73.7781° W, and Heathrow at 51.47° N, 0.4543° W. The great-circle distance is 5,540 km, or 3,442 miles, and 2,991 nautical miles.
The first heading is 51.4°, about northeast, even though London is east of New York on a map. Coming home, the first heading is 287.9°, which is no simple reverse. A real flight runs longer, because winds and airspace change the path.
Reading your result
A radical can be the exact answer. From (−3, −1) to (2, 3) the root does not simplify, so √41 stands. From (0, 0) to (6, 6) the root of 72 becomes 6√2. From (0, 0) to (3, 4) the root is whole: 5.
The order p decides how much one big difference counts. For (1, 2) and (4, 6), the distance is 7 at = 1, 5 at = 2, 4.5 at = 3, 4.02 at = 10. It settles toward 4, the largest difference, as grows.
Great-circle results are good to a fraction of a percent. Earth is slightly flattened, so a sphere is only an approximation. Errors can reach 0.55%, though they are usually below 0.3%. On this sphere, one degree along a meridian is 111.2 km. For surveying or aviation, use a tool built on an ellipsoid.
Miles and nautical miles are exact conversions. The mile is 1,609.344 m and the nautical mile is 1,852 m. Sydney to Tokyo comes to 7,826 km, or 4,226 nautical miles.
Common mistakes
- Adding before squaring. The root of a sum of squares is not the sum of the differences. For legs of 3 and 4, the distance is 5, not 7.
- Dropping a negative. Going from a negative coordinate adds, so −3 to 2 is a difference of 5, not 1. The squares then hide your slip if you never check the sign.
- Swapping latitude and longitude, or their signs. Latitude comes first, and south and west are negative. Leaving off the minus on a western longitude puts New York in Asia.
- Using the distance on a flat map. A straight ruler on a world map follows no shortest route, and its scale changes with latitude.
Questions people ask
Sources
- OpenStax, College Algebra 2e, section 2.1, The Rectangular Coordinate Systems and Graphs
- OpenStax, Calculus Volume 3, section 2.2, Vectors in Three Dimensions
- NIST Dictionary of Algorithms and Data Structures, Manhattan distance
- NIST Dictionary of Algorithms and Data Structures, Lm distance
- Moritz, H., Geodetic Reference System 1980
- Veness, C., Calculate distance, bearing and more between latitude/longitude points, Movable Type Scripts
- Williams, E., Aviation Formulary
- NIST Special Publication 811, Appendix B.9, Factors for units listed by kind of quantity