Geometry

Distance Between Two Points

Enter two points to get the straight-line distance, with the distance formula worked out, the exact answer as a simplified square root, the midpoint and more. Switch to map mode for latitude and longitude.

Point 1
Point 2
-
Working

    Runs entirely in your browser. Nothing is uploaded to any server.

    Why use this distance calculator

    Shows the formula

    Every step of the distance formula with your numbers.

    Exact answers

    Whole-number inputs give a simplified square root like 2√13.

    Three modes

    Flat 2D, 3D space, or real places on Earth.

    How to find the distance between two points

    1. Choose a mode2D, 3D or latitude and longitude.
    2. Enter both pointsType the coordinates of point 1 and point 2.
    3. Read the resultSee the distance, the working, the midpoint and the graph.

    The distance formula

    The distance between (x₁, y₁) and (x₂, y₂) comes from Pythagoras' theorem: the horizontal and vertical differences are the two short sides of a right triangle, so d = √((x₂ − x₁)² + (y₂ − y₁)²). In 3D you add the squared z-difference under the same square root.

    On the Earth's surface, straight lines become great circles. The haversine formula gives the shortest distance over a sphere using latitudes and longitudes, which is accurate to within about half a percent for the real, slightly flattened Earth.

    Midpoint

    The average of the coordinates: ((x₁ + x₂)/2, (y₁ + y₂)/2).

    Manhattan distance

    The sum of absolute differences, like walking a city grid.

    Bearing

    The compass direction to start in when travelling from point 1 to point 2.

    Distance between points FAQ

    What is the distance formula?

    d = √((x₂ − x₁)² + (y₂ − y₁)²) in 2D, and d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²) in 3D.

    Does the order of the points matter?

    No. The differences are squared, so swapping the points gives the same distance.

    How is the exact answer simplified?

    The largest perfect square is taken out of the square root. For example √52 = √(4 × 13) = 2√13.

    Why does the map distance differ from driving distance?

    The haversine result is the shortest path over the Earth's surface. Roads, flight paths and terrain make real routes longer.

    What Earth radius is used?

    The mean radius of 6,371.0088 km recommended by the International Union of Geodesy and Geophysics.

    Try other math tools

    More free tools from My Panda Toolbox.