Skip to main content

Distance, midpoint & circles

Distance Calculator

Calculate the straight-line distance between two points in 2D or 3D, or find the geographic distance between two locations using latitude and longitude. Uses the Haversine formula for great-circle (as-the-crow-flies) distance. Results in kilometers, miles, or nautical miles.

By Jeff Beem

Updated

Points & mode

Point 1: x, y
Point 2: x, y
Result
Distance in:5 units

Current calculation

d = √[(x₂−x₁)² + (y₂−y₁)²] = √[(3-0)² + (4-0)²] = 5

Using this calculator

Choose 2D or 3D for Cartesian coordinates (Euclidean distance), or Geographic for lat/lon (great-circle distance). For geo, use decimal degrees; the map draws the great-circle arc between the two points on a Mercator basemap. Drag markers or click to set points. For definitions and coordinate systems, see the article below.

Formulas used

2D (Euclidean): d = √[(x₂−x₁)² + (y₂−y₁)²]

3D (Euclidean): d = √[(x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²]

Geographic (Haversine, great-circle): Earth radius R = 6,371 km. Distance in km: d = 2R × atan2(√a, √(1−a)), where a = sin²(Δφ/2) + cos φ₁ cos φ₂ sin²(Δλ/2) (angles in radians).

Three modes

(0, 0) to (3, 4) is 5 in 2D; New York to London is about 5,570 km on the sphere. Pick the mode that matches your coordinate type, then read the result in your own units.

Choosing a mode

Flat (x, y) or (x, y, z)

Pick 2D or 3D depending on whether your data has a depth axis. Distance inherits your axis units, so meters in, meters out; pixels in, pixels out. The math is the Pythagorean theorem extended to three dimensions.

Two places on Earth

Geographic mode takes decimal degrees or DMS. Map markers stay synced with the input fields. Output toggles between kilometers, miles, and nautical miles, useful when comparing flight distances against shipping or hiking references.

Using the map

In Geographic mode, clicks alternate between Point 1 and Point 2. Drag pins to fine-tune; lat/lon and distance update live. Useful when you know roughly where two places are but do not want to hunt down exact coordinates first.

Crow-flies, not driving

Great-circle distance is what flights approximate, not what your car drives. For roads use a routing service. Vincenty on the WGS84 ellipsoid usually agrees with this Haversine sphere to within about 0.5%, which is good enough for everything except survey work.

Distance Calculator: 2D, 3D & Great-Circle Distance

(0, 0) to (3, 4) is 5 units in 2D; NYC (40.71° N, 74.01° W) to London (51.51° N, 0.13° W) is about 5,570 km great-circle. Flat Pythagorean or spherical Haversine, with map pins in Geographic mode.

How distance is computed

Flat coordinates use Pythagoras and inherit your axis units. Lat/lon uses Haversine on a sphere with R = 6,371 km, and the map draws the great-circle arc between pins.
  • 2D worked example:
    Point 1: (0, 0), Point 2: (3, 4) →
    d = √(3² + 4²) = 5
    Same units as x and y.
  • Geographic worked example:
    40.7128° N, 74.0060° W (New York) to 51.5074° N, 0.1278° W (London) is about 5,570 km Haversine. Tokyo to Los Angeles works out near 8,815 km on the same model. The curve looks longer on a Mercator map because flat maps stretch high latitudes.
  • What this misses:
    Road or driving distance, which needs a routing service. Ellipsoidal Vincenty/WGS84 geodesics, usually within ~0.5% of this sphere model on long routes. Geographic mode returns the surface arc, not the chord through the planet.
  • Also on screen:
    DMS and decimal lat/lon stay in sync with draggable markers; all math runs locally in your browser.

Euclidean vs great-circle

Flat coordinates use the Pythagorean theorem. Lat/lon uses Haversine on a sphere (R = 6,371 km).
  • 2D:
    d = √[(x₂x₁)² + (y₂y₁)²]
    Example: Δx = 3, Δy = 4 → d = 5.
  • 3D:
    Add (z₂z₁)² under the radical. Same units as your axes.
  • Geographic (Haversine):
    Shortest surface arc, not a straight line through the planet.
    d = 2R × atan2(√a, √(1−a))
    with
    a = sin²(Δφ/2) + cos φ₁ cos φ₂ sin²(Δλ/2)
    (φ, λ in radians). Crow-flies city pairs match flight planning at this precision; survey work may need an ellipsoid solver.

Coordinates and units

Cartesian: right-handed x, y, z; distance inherits those units. Geographic: latitude ±90° (N/S), longitude ±180° (E/W), decimal degrees or DMS. Sphere radius
R = 6,371 km
then convert display to miles or nautical miles as needed.

Distance Calculator FAQ

What is the 3D distance formula?

The 3D distance formula is the Euclidean distance between two points (x₁, y₁, z₁) and (x₂, y₂, z₂):
d = √[(x₂x₁)² + (y₂y₁)² + (z₂z₁)²]
It extends the 2D Pythagorean theorem by adding the z-difference. This distance calculator supports 2D, 3D, and geographic (lat/lon) modes.

How do I find distance on a map?

For distance on a map between two places, use latitude and longitude (decimal degrees). Enter the coordinates of both points, or use the interactive map to click or drag markers. The calculator uses the Haversine formula to compute the great-circle (air) distance. You can display the result in km, miles, or nautical miles.

Is the Earth a perfect sphere for these calculations?

The Haversine formula assumes a spherical Earth with radius 6,371 km, which is a good approximation for most purposes. For higher precision over long distances, the Vincenty formula uses an ellipsoid (WGS84); the difference is usually under 0.5%. This calculator uses Haversine for clarity and speed; for sub-meter accuracy over thousands of km, use a geodesic library.

What is the difference between Euclidean and geodesic distance?

Euclidean distance is the straight-line distance in flat (Cartesian) space, what you get with the 2D or 3D formula. Geodesic distance (great-circle distance) is the shortest path along the Earth’s surface between two points, an arc, not a straight line through the globe. For lat/lon, this calculator uses Haversine to compute geodesic distance in km.

How do I get latitude and longitude for a city?

Search for “latitude longitude [city name]” or use a site like OpenStreetMap. Enter coordinates in decimal degrees (e.g. 40.7128, -74.0060 for New York). This calculator also has an interactive map: switch to Geographic mode and drag the markers to set points; the lat/lon fields update automatically.

Mathematical Reference Note

Calculation Logic: This tool uses standard mathematical algorithms. While we strive for accuracy, errors in logic or user input can result in incorrect data.

Verification: Results should be cross-checked if used for important academic, professional, or personal calculations.

Standard Terms: This tool is provided free of charge and as-is. CalcRegistry provides no warranty regarding the accuracy or fitness of these results for your specific needs.

© 2026 CalcRegistry Reference Last System Check: May 2026Free Online Utility Tools