Distance Calculator

Distance = √((x₂ − x₁)² + (y₂ − y₁)²), with (z₂ − z₁)² added in three dimensions. The distance between (0, 0) and (3, 4) is √(9 + 16) = 5, and between (0, 0, 0) and (2, 3, 6) it is √(4 + 9 + 36) = 7.

Inputs

Result
–

Results are calculated in your browser for convenience. Double-check important figures before relying on them.

The distance formula

d = √((x₂ − x₁)² + (y₂ − y₁)²) d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)

This is the Pythagorean theorem applied to coordinates. The horizontal and vertical differences are the two legs of a right triangle, and the distance is the hypotenuse. For (1, 2) and (4, 6): the differences are 3 and 4, so d = √(9 + 16) = 5. The midpoint is the average of the coordinates: (2.5, 4).

Straight-line and grid distance

The straight-line (Euclidean) distance is the shortest path. The Manhattan distance, |Δx| + |Δy|, is the distance along a grid of streets and equals 7 for the example above. This calculator works for any units; the result is in the same unit as the coordinates. It is not for distances over the Earth’s surface between latitude and longitude points, which curve and need a great-circle formula.

Uses

  • Geometry homework, graphs and coordinate maps.
  • Game design and computer graphics.
  • Clustering and machine learning, where distances measure similarity.

Use the slope calculator for the line through the points and the Pythagorean theorem calculator for right triangles.

Complete guide to the Distance Calculator

How to use the Distance Calculator, step by step

  1. Choose 2D or 3D.
  2. Enter both points.
  3. Read the distance and midpoint.
  4. Check the Manhattan distance for grid travel.

Common mistakes to avoid

  • Forgetting to square the differences.
  • Using it for latitude and longitude.
  • Mixing units.

Key terms explained

Euclidean distance
The straight-line distance.
Midpoint
The point halfway between two points.
Manhattan distance
Distance along grid lines.
Coordinate
A position given by numbers.

Frequently asked questions

What is the distance formula?

It is d = √((x₂ − x₁)² + (y₂ − y₁)²). It comes from the Pythagorean theorem and gives the straight-line distance between two points.

How do I find the distance in 3D?

Add the squared difference of the z coordinates under the square root: √(Δx² + Δy² + Δz²).

What is the midpoint formula?

The midpoint is the average of the coordinates: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2), plus the same for z in three dimensions.

What is Manhattan distance?

It is the sum of the absolute differences of the coordinates, the distance you would travel along grid lines with no diagonal moves.

Can I use this for map coordinates?

Not for latitude and longitude over long distances, because the Earth is curved. For small areas on a flat map grid the formula works well.

Does the order of the points matter?

No. Squaring removes the sign, so the distance from A to B is the same as from B to A.

Can I find the distance between two points on a map?

For small areas on a flat grid the formula works well. For long distances over the Earth, use a great-circle formula with latitude and longitude instead, because the surface is curved.

Related calculators

Guides worth reading