Written by Erum Nazeer Built by Muhammad Ayaz Akhtar Updated

Maths calculator

Distance Calculator

Enter two points to calculate the straight-line distance between them, in 2D coordinate geometry, 3D space, or latitude/longitude for real-world locations. The same page covers the speed, distance, and time triangle formulas, flight distance, as-the-crow-flies estimates, and how this differs from Google Maps driving distance.

d = √((x2 - x1)² + (y2 - y1)²)

Point distance

Choose mode and enter points

Distance mode
P1 P2 distance
Formula: d = √((x2 - x1)² + (y2 - y1)²)

On This Page

Pick the Kind of Distance

You haveUseFormula
Two points (x, y) on a plane2D moded = √((x2 − x1)² + (y2 − y1)²)
Two points (x, y, z) in space3D modeAdd (z2 − z1)² inside the root
Two places as latitude and longitudeLat/Long modeHaversine great-circle formula
A speed and a timeArithmetic belowDistance = speed × time
Distance formula diagram showing two points P₁(x₁,y₁) and P₂(x₂,y₂) on a coordinate plane with the straight-line distance d and the right triangle formed by Δx and Δy
Two points P₁(x₁,y₁) and P₂(x₂,y₂) on a coordinate plane with straight-line distance d and the right triangle formed by Δx and Δy

Two Points on a Grid

The distance formula is Pythagoras: the gap is the hypotenuse of the right triangle made by the x and y differences. Subtract first, then square, so a negative difference does no harm, since (−6)² = 36.

The same two points define a line, and the Slope Calculator gives its slope, angle and equation. Positive vs negative slope covers reading whether it rises or falls.

Distance on the Earth

A flat-plane formula goes wrong over long distances because the Earth curves. Lat/Long mode uses the haversine formula, which gives the great-circle distance, the shortest path over the surface or "as the crow flies." Enter decimal degrees, with positive values for north and east and negative for south and west.

New York (40.7128, −74.0060) to Los Angeles (34.0522, −118.2437) comes out at about 3,936 km or 2,446 miles, and New York to London (51.5074, −0.1278) at about 5,570 km. The result treats the Earth as a perfect sphere, so it can be up to about 0.3% out. It is close to air distance, which is why flight planning starts from it; the Flight Distance Calculator adds airport lookups, flight time and CO₂. Numbers this large are also where scientific notation becomes handy.

This is not driving distance. Google Maps' "Measure distance" tool (right-click a point) draws the same straight line, but "Get directions" follows roads and is always as long or longer. Walking and running routes are longer than the straight line too.

Speed, Distance and Time

FindFormulaExample
Distancespeed × time60 mph for 2.5 h = 150 miles
Timedistance ÷ speed240 km at 80 km/h = 3 h
Speeddistance ÷ time180 miles in 3 h = 60 mph

Put time in hours before multiplying: 45 minutes is 0.75 hours, so a runner at 8 mph for 45 minutes covers 6 miles. A 10 km run in 50 minutes (0.833 h) is about 12 km/h, and a 10-minute mile is 6 mph.

Everyday Distance Rules of Thumb

How the Calculator Is Verified

Switching to lat/long mode swaps in the haversine formula entirely, converting each coordinate to radians and using an Earth radius of 3958.8 miles or 6371 kilometers depending on the selected unit, a calculation with nothing in common with the other two modes. 2D and 3D actually share one function: distance = sqrt(dx² + dy² + dz²); in 2D mode the code simply sets z1 and z2 to 0 before running it, so the same formula produces both the flat and spatial result. That is why a 3D calculation with z=0 for both points always matches the 2D answer for identical x,y values.

Frequently Asked Questions

What is the difference between distance and displacement?

Distance is the total length of the path travelled, always positive. Displacement is the straight-line change in position from start to finish, with direction. Walking 3 miles east then 3 miles west gives distance = 6 miles but displacement = 0.

Is latitude-longitude distance exact?

It is a close estimate. The Haversine formula assumes a perfectly spherical Earth. Earth is slightly flattened at the poles, so real great-circle distances can differ by up to about 0.3%. For city distances and flight estimates, it is accurate enough.

References