Math & StatisticsFormula-based · Runs in your browser

Distance Calculator

Calculate distance in 2D, 3D, or between two latitude/longitude coordinates on Earth.

Preparing saved example…

Inputs

Enter the values you know. Optional fields may be left empty.

Local save controls below
Required
Required
Required
Required
Required

Result

Updates as valid inputs change.

Calculated locally
Distance
Distance
Distance
Δx
Δy
Δz
Initial bearing
Midpoint

Saved locally, explained clearly

Drafts, calculations, scenarios, and workflow progress stay in this browser unless you export them.

Opening local database…

Calculation steps

Follow what happened from the selected formula to the displayed answer.

Show substituted values and intermediate working
Calculate current inputs to see the working.
  1. 1

    Formula selected

    The calculator uses the following formula or method.

    Cartesian: d=√[Σ(qᵢ−pᵢ)²]; geographic: d=2R·asin(√[sin²(Δφ/2)+cosφ₁cosφ₂sin²(Δλ/2)]).

  2. 2

    Values entered

    Your values are placed into the calculation.

    Enter values to see what is used in this step.

  3. 3

    Result calculated

    The formula or method produces the following result values.

    Results will appear after a successful calculation.

  4. 4

    Answer formatted

    Displayed values are rounded and formatted using each output’s configured precision.

Scenario comparison

Save working scenarios, then select two or three to compare. Formula versions and inputs remain visible.

No scenarios saved for this calculator yet.

Recent calculations

Successful calculations are retained locally according to your privacy settings.

No local history for this calculator yet.

Data and privacy

How it works

Calculate distance in 2D, 3D, or between two latitude/longitude coordinates on Earth. Inputs are calculated locally in the browser, and valid values are retained in the page URL for bookmarking.

Input query strings and outputs

Use an input name in this page’s URL as ?name=value, and join additional inputs with &. Portable shared links may instead use the compact ?ac= state parameter.

Input query strings

15
  • ?mode= Distance model

    Choice · Required · Default: 2d · Accepted values: 2d, 3d, geographic

  • ?x1= x₁

    Number · Required · Default: 0 · Used when mode = 2d

  • ?y1= y₁

    Number · Required · Default: 0 · Used when mode = 2d

  • ?x2= x₂

    Number · Required · Default: 3 · Used when mode = 2d

  • ?y2= y₂

    Number · Required · Default: 4 · Used when mode = 2d

  • ?x1Three= x₁

    Number · Required · Default: 0 · Used when mode = 3d

  • ?y1Three= y₁

    Number · Required · Default: 0 · Used when mode = 3d

  • ?z1Three= z₁

    Number · Required · Default: 0 · Used when mode = 3d

  • ?x2Three= x₂

    Number · Required · Default: 3 · Used when mode = 3d

  • ?y2Three= y₂

    Number · Required · Default: 4 · Used when mode = 3d

  • ?z2Three= z₂

    Number · Required · Default: 12 · Used when mode = 3d

  • ?latitude1= Latitude 1

    Number · Required · Default: 40.7128 · Used when mode = geographic

  • ?longitude1= Longitude 1

    Number · Required · Default: -74.006 · Used when mode = geographic

  • ?latitude2= Latitude 2

    Number · Required · Default: 51.5074 · Used when mode = geographic

  • ?longitude2= Longitude 2

    Number · Required · Default: -0.1278 · Used when mode = geographic

Outputs

8
  • distance Distance

    Number · Primary output

  • distanceKilometers Distance

    Number · Suffix: km

  • distanceMiles Distance

    Number · Suffix: mi

  • deltaX Δx

    Number

  • deltaY Δy

    Number

  • deltaZ Δz

    Number

  • initialBearing Initial bearing

    Number · Suffix: °

  • midpoint Midpoint

    Text

Formula notes

Cartesian: d=√[Σ(qᵢ−pᵢ)²]; geographic: d=2R·asin(√[sin²(Δφ/2)+cosφ₁cosφ₂sin²(Δλ/2)]).

Input guidance

Use consistent units for every length or measurement in the same calculation. Results are educational mathematical estimates and should be checked before high-stakes use.

Sources
Limitations
  • Results depend on the selected method and input assumptions. Displayed decimals may be rounded; retain appropriate precision for later calculations.