Distance Calculator

Dimensions
Distance5.0000
Slope1.3333
Midpoint(1.50, 2.00)

This distance calculator measures the straight-line gap between two points using the coordinate distance formula, in either two or three dimensions. For 2D points it also returns the slope of the connecting line and the midpoint between them. It is built on the Pythagorean theorem, where the distance is the square root of the summed squared differences of the coordinates.

Formula

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

x₁, y₁, z₁
Coordinates of the first point (z used only in 3D mode)
x₂, y₂, z₂
Coordinates of the second point (z used only in 3D mode)
d
Straight-line (Euclidean) distance between the points

How it works

  1. Enter the coordinates of the first point and the second point. Toggle 3D mode on to add z-coordinates for points in space.
  2. The calculator squares the difference in each coordinate, adds the squares, and takes the square root to get the Euclidean distance.
  3. For 2D points it also reports the slope (rise over run) and the midpoint; the slope is shown as undefined for a vertical line where the x-values match.

Worked example

Find the distance between the 2D points (1, 2) and (4, 6).

  1. Differences: x₂−x₁ = 3 and y₂−y₁ = 4.
  2. Square and sum: 3² + 4² = 9 + 16 = 25.
  3. Square root: √25 = 5.

The distance is 5, the slope is 4/3 ≈ 1.3333, and the midpoint is (2.5, 4).

Frequently asked questions

How is the 3D distance different from the 2D distance?
The 3D version adds a third squared term, (z₂−z₁)², under the square root. In 2D mode only the x and y differences are used.
When is the slope undefined?
The slope is rise over run, so it is undefined when the run is zero — that is, when both points share the same x-coordinate and the line is vertical. The calculator reports it as undefined in that case.
What is the midpoint?
The midpoint is the point exactly halfway between the two, found by averaging the x-coordinates and averaging the y-coordinates. It always lies on the straight line connecting them.
Is this the same as the Pythagorean theorem?
Yes. The distance formula is a direct application of the Pythagorean theorem, treating the coordinate differences as the legs of a right triangle whose hypotenuse is the distance.