Skip to content
CalculatorBuddy

Distance Calculator

Find the distance between two points on a 2D plane or in 3D space, or the shortest (great-circle) distance between two latitudes and longitudes on Earth.

Distance between two points on a coordinate plane, plus slope, θ, and the line equation.

ExampleSample values — edit any field to see your result.

x-coordinate of the first point.

y-coordinate of the first point.

x-coordinate of the second point.

y-coordinate of the second point.

Results update as you type.

Distance (d)

5

Estimated result

ΔX
3
ΔY
4
Slope (m)
1.3333333333333
Rise over run
4/3 = 1.3333333333333
Angle of incline (θ)
53.130102354156°
Equation of the line
y = 1.3333333333333x - 0.33333333333333
Equation (fraction form)
y = (4/3)x - 1/3
When x = 0
-0.33333333333333
When y = 0
0.25

Calculation steps

Worked solution
d = √((4 - 1)² + (5 - 1)²)
= √((3)² + (4)²)
= √25
= 5

Find the distance between two points on a 2D plane or in 3D space, or the shortest distance along Earth's surface between two latitudes and longitudes. 2D results also include slope, the incline angle, and the equation of the line through the points.

Formula

On a plane the distance is the Pythagorean theorem:

d = √((x₂ − x₁)² + (y₂ − y₁)²)

In 3D, add the z-term:

d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)

On Earth, Lambert's formula uses the haversine central angle σ on reduced latitudes β (tan β = (1 − f) tan φ), then

d = a (σ − (f/2)(X + Y))

with equatorial radius a = 6,378.1 km and flattening f = 1/298.257. Miles are km / 1.60935. This is air / great-circle distance, not a road route.

The default 2D example is (1, 1) and (4, 5): d = 5, m = 4/3, θ ≈ 53.130102354156°. The default Earth pair is the White House to Philadelphia: 200.0 km or 124.3 miles.

Worked identities

PointsDistance
(1, 1) and (4, 5)5
(1, 5) and (3, 2)√13 ≈ 3.605551275464
(0, 0) and (2, 2)2√2 ≈ 2.8284271247462
(1, 1, 1) and (2, 2, 2)√3 ≈ 1.7320508075689
(0, 0, 0) and (2, 2, 2)2√3 ≈ 3.4641016151378
38.8976, −77.0366 to 39.9496, −75.1503200.0 km or 124.3 miles

Examples

2D 3-4-5 triangle (default)

Points (1, 1) and (4, 5). ΔX = 3, ΔY = 4, so d = √(9 + 16) = 5. Slope is 4/3 ≈ 1.3333333333333 and θ ≈ 53.130102354156°. The line is y = (4/3)x − 1/3.

3D unit cube diagonal (default)

Points (1, 1, 1) and (2, 2, 2). Each coordinate changes by 1, so d = √3 ≈ 1.7320508075689.

White House to Philadelphia

Decimal 38.8976, −77.0366 to 39.9496, −75.1503, or DMS 38° 53' 51.36" N, 77° 2' 11.76" W to 39° 56' 58.56" N, 75° 9' 1.08" W. Lambert's formula gives 200.0 km or 124.3 miles.

Frequently asked questions

How do I find the distance between two points on a plane?
Use the distance formula d = √((x₂ − x₁)² + (y₂ − y₁)²). The order of the points does not matter. Points (1, 5) and (3, 2) are √13 ≈ 3.605551275464 apart. The default example (1, 1) and (4, 5) is a 3-4-5 triangle, so d = 5. This tab also reports slope, the incline angle, and the line equation.
How is 3D distance different from 2D?
Add the z-coordinates: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). Points (1, 3, 7) and (2, 4, 8) are √3 ≈ 1.7320508075689 apart. The default (1, 1, 1) to (2, 2, 2) is the same √3. When a square factor remains, the result is printed as a simplified radical, for example 2√3 or 3.4641016151378.
How is distance on Earth calculated?
Latitude and longitude use Lambert's formula for the shortest path on an ellipsoid (great-circle / air distance), not driving distance. The central angle comes from the haversine formula on reduced latitudes, then a flattening correction. The equatorial radius is 6,378.1 km and flattening is 1/298.257. Accuracy is on the order of 10 meters over thousands of kilometers. Terrain, roads, and altitude are not included.
What is the difference between decimal and DMS coordinates?
Decimal degrees are a single signed number (38.8976, −77.0366). DMS splits that into degrees, minutes, seconds, and a hemisphere. 38° 53' 51.36" N, 77° 2' 11.76" W is the same as 38.8976, −77.0366. Both tabs use the same Lambert formula. Negative decimal latitude is south; negative longitude is west.
Can I click two points on a map?
This calculator does not embed a map. Enter the two coordinates on the Lat/Long or DMS tab instead — that is the same Lambert distance the source map would show. Pair it with the Conversion Calculator if you need the result in feet or nautical miles.

Related calculators