Skip to main content

2D, 3D & air distance

Distance Calculator

This calculator finds straight-line distance between two points in 2D or 3D using the Pythagorean theorem, or air distance between two lat/lon pairs using the Haversine great-circle formula (R = 6,371 km). Geographic mode includes an interactive map and live formula substitution. Crow-flies only—not driving or walking routes.

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

How to use this calculator

The form opens in 2D (x, y) with (0, 0) and (3, 4), so Result shows Euclidean distance 5 units. Use the Mode dropdown for 3D coordinates or Geographic (lat/lon).

In Geographic mode, enter decimal degrees or DMS for Point 1 and Point 2, or click the map (first click sets Point 1, second sets Point 2, then they alternate). Defaults are New York to Los Angeles (~3,936 km air distance). Drag pins to refine; lat/lon fields stay in sync.

Result lists great-circle length in km, miles, nautical miles, and other units. The Current calculation panel under Result shows Haversine intermediate values for your coordinates. This is crow-flies distance, not driving or walking routes.

Formulas used

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

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

Geographic: Haversine great-circle (R = 6,371 km)—switch to Geographic mode for the live breakdown.

Reading your results

Match the Mode dropdown to your data: 2D or 3D for flat coordinates, Geographic for lat/lon and the map. Why great-circle routes look curved on flat maps is covered in Why planes fly in curves.

Example: 2D default (0, 0) → (3, 4)

The form opens in 2D (x, y) with Point 1 at (0, 0) and Point 2 at (3, 4). The Result panel shows Euclidean distance 5 units (same units as x and y). Switch to 3D (x, y, z) to include a z axis.

Example: Geographic default NYC → Los Angeles

In Geographic (lat/lon), defaults are New York (40.7128°, −74.0060°) and Los Angeles (34.0522°, −118.2437°). Result lists km, miles, nautical miles, and other lengths; the map draws the great-circle arc. Air distance is about 3,936 km (2,446 mi), not road miles.

Current calculation (Geographic only)

Below Result, the Current calculation panel shows Haversine intermediate a, central angle, and substituted lat/lon values as you edit fields or drag map pins. Use it to verify hand math against Paris–Kraków (~1,276 km) or your own pair.

Distance Between Two Points: 2D, 3D & Great-Circle

Euclidean distance in flat coordinates or Haversine great-circle between two lat/lon points. Interactive map and live formula substitution in Geographic mode.

What each mode returns

2D and 3D use the Pythagorean theorem in Cartesian space—units follow your axes. Geographic uses Haversine on a sphere (R = 6,371 km) and draws the matching great-circle arc on the map.
  • 2D example:
    (0, 0) to (3, 4) → d = √(3² + 4²) = 5 (same units as x and y).
  • Geographic example:
    New York (40.7128°, −74.0060°) to London (51.5074°, −0.1278°) → about 5,570 km great-circle. Default NYC–Los Angeles is about 3,936 km.
  • Limits:
    Not road or driving distance. Not ellipsoidal survey precision—use Vincenty/WGS84 when sub-percent accuracy matters. Returns surface arc length, not a chord through the Earth.

Formulas

φ is latitude and λ is longitude (GIS convention). Angles inside Haversine trig must be in radians.
  • 2D:
    d = √[(x₂x₁)² + (y₂y₁)²]
  • 3D:
    Add (z₂z₁)² under the radical.
  • Geographic (Haversine):
    a = sin²(Δφ/2) + cos φ₁ cos φ₂ sin²(Δλ/2)
    d = 2R × atan2(√a, √(1−a))
    Equivalent to d = 2R × sin⁻¹(√a); atan2 is preferred when points are very close.

Result and Current calculation panels

Outputs update as you type or drag map markers. Invalid lat/lon (outside ±90° / ±180°) clears Result until both points are valid.
  • Result (2D/3D):
    One Euclidean distance labeled in axis units. Standard vs Compact toggles number formatting only.
  • Result (Geographic):
    Same great-circle distance in nautical miles, miles, kilometers, yards, meters, feet, inches, and centimeters.
  • Current calculation:
    Geographic mode only: substituted Haversine with your Point 1 and Point 2 lat/lon, intermediate a, and central angle. Copy results exports mode, coordinates, distance, and breakdown text.
  • Map:
    Geographic mode only: great-circle polyline between pins; clicks set Point 1 then Point 2, then alternate.

Distance Calculator FAQ

How do I calculate distance from latitude and longitude?

Switch to Geographic (lat/lon), enter both points in decimal degrees or DMS, and read great-circle distance in the Result panel. The math is Haversine on a sphere (R = 6,371 km): convert φ and λ to radians, compute a = sin²(Δφ/2) + cos φ₁ cos φ₂ sin²(Δλ/2), then d = 2R × atan2(√a, √(1−a)). Paris (48.8566°, 2.3522°) to Kraków (50.0647°, 19.9450°) is about 1,276 km on this model. The Current calculation box substitutes your live lat/lon values.

Why does this calculator use atan2 instead of arcsin for Haversine?

Both d = 2R × sin⁻¹(√a) and d = 2R × atan2(√a, √(1−a)) return the same great-circle distance. atan2 stays stable when two points are very close and a is tiny. Geographic mode shows both forms in Current calculation so you can cross-check.

What is the 3D distance formula?

Euclidean distance between (x₁, y₁, z₁) and (x₂, y₂, z₂):
d = √[(x₂x₁)² + (y₂y₁)² + (z₂z₁)²]
Same units as your axes. 2D drops the z term.

How do I find distance on a map?

Switch to Geographic (lat/lon), enter decimal degrees or DMS, or click the map (clicks alternate Point 1 and Point 2). Drag markers to refine. Distance is great-circle (crow-flies), not driving; use a routing app for road miles.

Is the Earth a perfect sphere for these calculations?

Haversine assumes a sphere (R = 6,371 km). For survey-grade work over long spans, use a WGS84 ellipsoid solver (Vincenty); difference from this model is usually under 0.5%.

What is the difference between Euclidean and geodesic distance?

Euclidean is straight-line distance in flat x/y/z space. Geodesic (great-circle) is the shortest arc on the Earth’s surface between two lat/lon points. Flights approximate geodesic; your car follows roads.

How do I get latitude and longitude for a city?

Search “latitude longitude [city]” or pick the place in OpenStreetMap. Enter decimal degrees (west and south negative), e.g. 40.7128, -74.0060 for New York. DMS entry is supported and stays synced with the map markers.

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: July 2026Free Online Utility Tools