🧮
🧮 Math & statistics

Distance & Midpoint Calculator (2D/3D)

Results update as you type.

Your numbers

Understanding the distance and midpoint calculator — concept and principle

Given two points, this calculator finds the straight-line (Euclidean) distance between them, the midpoint halfway between them and, for points in a plane, the slope of the line through them. It works in two dimensions (leave both z values at 0) or in three. It is used for coordinate geometry homework, map grids, CAD drawings and game programming.

Points (1, 2) and (4, 6) joined by a 3-4-5 right triangleFrom (1, 2) to (4, 6) you go 3 across and 4 up, so the straight line is √(9 + 16) = 5. The midpoint, halfway along both directions, is (2.5, 4), and the slope is 4 ÷ 3 ≈ 1.33.Straight-line distance is a hypotenuse0123450246(1, 2)(4, 6)Δx = 3Δy = 4M√(3² + 4²) = √25distance = 5((1+4)/2, (2+6)/2)midpoint (2.5, 4)slope Δy ÷ Δx = 4 ÷ 3≈ 1.333D: add (z₂ − z₁)²here z = 0
Distance = √(Δx² + Δy²); the midpoint averages the coordinates.

How it is calculated

The distance is in the coordinate unit; the slope has no unit.

The principle

The distance formula is the Pythagorean theorem on a coordinate grid. The horizontal difference Δx and the vertical difference Δy are the two legs of a right triangle, and the segment between the points is its hypotenuse, so d² = Δx² + Δy². In three dimensions you apply the theorem a second time with the depth difference Δz, which adds a third squared term. Squaring removes the signs, so it does not matter which point you call the first.

The midpoint is the average of the coordinates, because moving half of Δx and half of Δy from the first point lands exactly halfway along the segment. The slope is "rise over run": how much y changes for each unit of x.

Worked example

  1. Inputs: P₁ = (1, 2, 0), P₂ = (4, 6, 0).
  2. Differences: Δx = 3, Δy = 4, Δz = 0.
  3. Distance: √(3² + 4² + 0²) = √25 = 5.
  4. Midpoint: ((1 + 4)/2, (2 + 6)/2, 0) = (2.5, 4, 0).
  5. Slope: 4 ÷ 3 ≈ 1.333333333.
How Distance changes with y₂How Distance changes with y₂246810121.534.567.5912Example: 5y₂
Each point is the calculator re-run with only “y₂” changed; the gold point is the default example. Change the inputs above and this chart follows your numbers.
y₂Distance
1.53.041381265
33.16227766
4.53.905124838
65
7.56.264982043
97.615773106
1210.44030651

How to read the result

A distance of 5 means the segment is 5 units long however it is oriented. The midpoint (2.5, 4) is equally far, 2.5 units, from each end. A slope of 1.33 means y rises 4 units for every 3 units of x; a positive slope rises to the right, a negative slope falls, 0 is horizontal, and a vertical line (x₁ = x₂) has no defined slope. In 3D the slope output only describes the shadow of the segment on the xy-plane.

Common mistakes

Keep in mind: The result is the straight-line distance in a flat (Euclidean) space. Travel distance along roads, distance on a curved surface, or distance in grids where only horizontal and vertical moves are allowed (Manhattan distance) can be very different.

Frequently asked questions

How do I find the second endpoint if I know one endpoint and the midpoint?

Double the midpoint and subtract the known endpoint: P₂ = 2M − P₁. With M = (2.5, 4) and P₁ = (1, 2), P₂ = (4, 6).

What is the Manhattan distance between the example points?

|Δx| + |Δy| = 3 + 4 = 7, the length of a path that moves only along the grid lines.

Can the distance be negative?

No. It is a square root of a sum of squares, so it is always zero or positive and zero only when the points coincide.

Sources: Euclid, Elements, Book I, Proposition 47 (Pythagorean theorem) · J. Stewart, Calculus: Early Transcendentals, Cengage, section on three-dimensional coordinate systems

Checked 8 Nov 2026. Standard formulas, computed in your browser with double-precision numbers.

🧮 All math & statistics tools →🌍 Calculators by country →