Distance Calculator

Three Kinds of "Distance"

How far apart two points are depends entirely on what kind of space they live in. Two points on a graph use straight-line geometry; two points in a 3D model add a depth axis; two points on Earth's surface have to account for the planet's curvature. This calculator handles all three, switching the underlying formula based on which type of coordinates are supplied.

The Formulas

2D Points: d = √((x2−x1)² + (y2−y1)²)
3D Points: d = √((x2−x1)² + (y2−y1)² + (z2−z1)²)
Geographic (Haversine): a = sin²(Δφ/2) + cos(φ1)×cos(φ2)×sin²(Δλ/2)
c = 2 × atan2(√a, √(1−a)), d = R × c

The 2D and 3D formulas are both direct extensions of the Pythagorean theorem. The geographic mode instead uses the haversine formula, which accounts for the curvature of a sphere with radius R = 6,371 km rather than treating latitude and longitude as flat grid coordinates.

Where Each Mode Applies

  • 2D points — distance between locations on a map, a floor plan, or a scatter plot.
  • 3D points — distance between objects in CAD models, game engines, or physical space with height involved.
  • Geographic coordinates — flight distances, shipping routes, and any calculation using real latitude/longitude pairs.
Worked examples
ModePointsResult
2D(1, 2) to (4, 6)5
3D(0, 0, 0) to (3, 4, 12)13
GeographicNew York (40.7128, -74.0060) to London (51.5074, -0.1278)5,570.22 km (3,461.17 mi)

The New York–London figure is the great-circle (as-the-crow-flies) distance, which is shorter than any real flight path that has to account for air routes and wind patterns.

How to Use This Calculator

  1. Select a mode: 2D Points, 3D Points, or Geographic Coordinates.
  2. For 2D, enter X1, Y1, X2, Y2. For 3D, also enter Z1 and Z2.
  3. For Geographic mode, enter Latitude 1, Longitude 1, Latitude 2, and Longitude 2.
  4. Select Calculate to see the distance (in kilometers and miles for geographic mode).

Related Calculations

Working strictly in 2D and want a simpler dedicated tool? Try the Euclidean Distance Calculator or the Manhattan Distance Calculator for grid-based distance.