Distance Calculator

Find the distance between two 2D or 3D points with worked steps, plus the midpoint and slope, or estimate great-circle distance from latitude and longitude.

Check your inputs—Complete valid inputs to calculate a current result.
coordinate units

-1,000,000,000 – 1,000,000,000 coordinate units

coordinate units

-1,000,000,000 – 1,000,000,000 coordinate units

coordinate units

-1,000,000,000 – 1,000,000,000 coordinate units

coordinate units

-1,000,000,000 – 1,000,000,000 coordinate units

Straight-line distance

5.0000 coordinate units

  • Change in x3.0000
  • Change in y4.0000
  • Midpoint(1.5, 2)
  • Slope of the segment1.333333333 (4/3)

Use the same coordinate scale on all axes. This computes straight-line distance, not travel distance.

How this was calculated

  1. Find how far apart the points are in the x (left–right) direction: take the first point’s x away from the second point’s x.Δx = x₂ − x₁Put in your numbers: Δx = 3 − 0Answer: Δx = 3
  2. Find how far apart the points are in the y (up–down) direction: take the first point’s y away from the second point’s y.Δy = y₂ − y₁Put in your numbers: Δy = 4 − 0Answer: Δy = 4
  3. Square each difference (multiply it by itself), add the squares, then take the square root. This is the Pythagorean theorem (a² + b² = c² for a right triangle).d = √((Δx)² + (Δy)²)Put in your numbers: d = √(3² + 4²) = √(9 + 16) = √25Answer: d = 5 coordinate units
  4. The midpoint (the point exactly halfway between) is the average of each pair of coordinates: add them and divide by 2.M = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2)Put in your numbers: M = ((0 + 3) ÷ 2, (0 + 4) ÷ 2)Answer: M = (1.5, 2)
  5. The slope (how steep the line is) is the change in y divided by the change in x: rise over run.m = Δy ÷ ΔxPut in your numbers: m = 4 ÷ 3Answer: m = 4/3 = 1.333333333

Distance between points in simple words

Points on a graph have an address: x says how far across and y says how far up. To find the straight-line distance between two points, first find how far across and how far up you must go.

Those two moves make the two short sides of a right triangle. The distance is the long side, and the Pythagorean theorem finds it: square the two moves, add them, and take the square root.

Example: from (1, 2) to (4, 6) you go 3 across and 4 up. 3² + 4² = 9 + 16 = 25, and √25 = 5, so the points are 5 units apart. The midpoint, exactly halfway between, is (2.5, 4).

Places on Earth sit on a curved ball, so for latitude and longitude the calculator uses a formula made for a sphere instead.

Formula and method

Euclidean distance is √[(x₂ − x₁)² + (y₂ − y₁)²], adding (z₂ − z₁)² in 3D. Geographic mode uses the haversine formula on a sphere of radius 6,371.0088 km.

Worked example

Points (0, 0) and (3, 4) are √(9 + 16) = 5 coordinate units apart.

Midpoint and slope

Along with the distance, the calculator gives the midpoint, ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2), and in 2D the segment's slope Δy ÷ Δx as a reduced fraction. Points (1, 2) and (4, 6) are √(3² + 4²) = √25 = 5 apart, with midpoint (2.5, 4) and slope 4/3.

In 3D mode, Δz joins the sum under the root and the midpoint gains a z coordinate. Points (0, 0, 0) and (1, 2, 2) are √(1 + 4 + 4) = 3 apart, with midpoint (0.5, 1, 1).

Frequently asked questions

How do I find the distance between two points?

Subtract the coordinates, square the differences, add them and take the square root. From (1, 2) to (4, 6), Δx = 3 and Δy = 4, so d = √(9 + 16) = 5.

Is geographic mode road distance?

No. It estimates the shortest arc on a spherical Earth. Roads, elevation and ellipsoidal surveying require other data.

References

Last updated . Results are estimates for informational purposes only.