MATHS TOOL · 2D, 3D AND POINT TO LINE

Distance Between Two Points Calculator

Find the distance between two points on a graph in 2D or 3D, or from a point to a line. Enter whole numbers, decimals or fractions and get the exact answer in simplest radical form, the decimal value, every step of the working and a graph.

Exact radical answers · Fractions and negatives · Step-by-step working

Calculate the Distance

Point 1

Point 2

Point P (distance from P to the line through points 1 and 2)

Fractions (3/4), negatives and decimals work. For places on Earth, use the coordinates calculator instead — the formula below assumes a flat plane.

The distance formula

In two dimensions the distance between (x₁, y₁) and (x₂, y₂) comes from Pythagoras’ theorem:

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

In three dimensions add the z term: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). The distance from a point P(x₀, y₀) to the line through two points is |(y₂ − y₁)x₀ − (x₂ − x₁)y₀ + x₂y₁ − y₂x₁| ÷ √((y₂ − y₁)² + (x₂ − x₁)²).

Worked example

From (3, 2) to (7, 5): Δx = 4, Δy = 3, so d = √(4² + 3²) = √25 = 5. The midpoint is (5, 3.5) and the slope is 3/4 = 0.75.

This is straight-line (Euclidean) distance on a flat plane. For places on Earth use a great-circle calculation, which accounts for the planet’s curve.

3

ways to measure: 2D, 3D and point to line

2√13

exact answers in simplest radical form

4

steps in the working, shown every time

2

distances: Euclidean and Manhattan

How do you find the distance between two points?

Draw a right-angled triangle with the two points at the ends of the long side. The horizontal side is the difference in x (Δx = x₂ − x₁) and the vertical side is the difference in y (Δy = y₂ − y₁). By Pythagoras’ theorem, a² + b² = c², so the distance is:

d = √((x₂ − x₁)² + (y₂ − y₁)²)
  1. Subtract the x-coordinates and the y-coordinates.
  2. Square both differences.
  3. Add the squares.
  4. Take the square root.
Graph of points A(−2, 3) and B(4, −5) with a right triangle: Δx = 6, Δy = −8, distance = √100 = 10

Order and negative numbers

The order of the points does not matter: (x₁ − x₂)² is the same as (x₂ − x₁)², because squaring removes the minus sign. Negative coordinates work the same way: from (−2, 3) to (4, −5), Δx = 6 and Δy = −8, so d = √(36 + 64) = √100 = 10.

Distance from the origin

If one point is the origin (0, 0), the formula shortens to d = √(x² + y²). In 3D it is √(x² + y² + z²).

Exact answers: simplifying the radical

Many distances are not whole numbers, and teachers usually want the exact answer rather than a rounded decimal. To simplify a square root, take out the largest square factor. The calculator does this automatically and shows both forms; when you enter fractions, it keeps the arithmetic exact until the last step.

Square rootLargest square factorSimplest formDecimal
√842√22.8284
√4593√56.7082
√50255√27.0711
√5242√137.2111
√72366√28.4853
√98497√29.8995

TWO KINDS OF DISTANCE

Euclidean vs Manhattan distance

The distance formula gives the Euclidean distance: the straight line between the points. The Manhattan (taxicab) distance is |x₂ − x₁| + |y₂ − y₁|, the distance you would travel along a grid of streets, moving only horizontally and vertically.

From (1, 1) to (5, 7) the Euclidean distance is √52 ≈ 7.21, while the Manhattan distance is 4 + 6 = 10. The calculator shows both.

Grid of city blocks from (1, 1) to (5, 7): the straight-line Euclidean distance is √52 ≈ 7.21 and the Manhattan distance along the streets is 10

Distance in 3D, to a line and to a plane

The same idea, the shortest straight line, works in more dimensions and for lines and planes.

Two points in 3D

Add the z-difference inside the square root.

d = √(Δx² + Δy² + Δz²)

Example: (1, 2, 3) to (4, 6, 15) gives √(9 + 16 + 144) = √169 = 13.

Point to a line

The shortest distance is along the perpendicular. For the line ax + by + c = 0 and point (x₁, y₁):

d = |a·x₁ + b·y₁ + c| ÷ √(a² + b²)

Example: (3, 4) to 3x + 4y − 10 = 0 gives |9 + 16 − 10| ÷ 5 = 3.

Point to a plane

For the plane Ax + By + Cz + D = 0 and point (x₁, y₁, z₁), measure along the normal:

d = |A·x₁ + B·y₁ + C·z₁ + D| ÷ √(A² + B² + C²)

A line parallel to a plane is the same distance from it everywhere, so any point on the line works.

Use the Point to line tab: enter two points on the line and the point P. The calculator finds the line’s equation, the distance and the foot of the perpendicular. For two parallel lines ax + by + c₁ = 0 and ax + by + c₂ = 0, the distance between them is |c₂ − c₁| ÷ √(a² + b²).

Distance between two points on a map

Places on a map

For two real places, use the crow flies calculator: it measures the distance between two points on a map over the curved Earth.

GPS coordinates

For latitude and longitude, the flat distance formula is not accurate. Use the coordinates calculator, which works on the WGS84 ellipsoid.

Google Maps

To measure between two points on Google Maps, right-click, choose Measure distance and click the second point. See our Google Maps guide.

Common mistakes

  • Forgetting that a negative difference squared is positive: (−3)² = 9, not −9.
  • Subtracting x from y: always pair x₂ with x₁ and y₂ with y₁.
  • Taking the square root of each part separately: √(9 + 16) is 5, not 3 + 4 = 7.
  • Rounding too early: keep the exact radical until the final answer.

Frequently asked questions

How do you find the distance between two points?

Subtract the x-values and the y-values, square both differences, add them, and take the square root.

What is the distance formula?

d = √((x₂ − x₁)² + (y₂ − y₁)²). It is Pythagoras’ theorem applied to coordinates.

Does the order of the points matter?

No. Squaring the differences removes any minus sign, so you get the same answer either way.

How do you find the distance between two points in 3D?

Add (z₂ − z₁)² inside the square root: d = √(Δx² + Δy² + Δz²).

What is the difference between Euclidean and Manhattan distance?

Euclidean distance is the straight line between the points. Manhattan distance is |Δx| + |Δy|, the distance along a grid.

How do you find the distance from a point to a line?

Write the line as ax + by + c = 0 and use d = |ax₁ + by₁ + c| ÷ √(a² + b²). This is the perpendicular, shortest distance.

What is the distance from a point to a plane?

For the plane Ax + By + Cz + D = 0 it is |Ax₁ + By₁ + Cz₁ + D| ÷ √(A² + B² + C²).

Why give the answer as a radical?

A radical such as 2√13 is exact. The decimal 7.2111 is only an approximation.

How do I find the distance between two points on a map?

Use the crow flies calculator for places, or the coordinates calculator for latitude and longitude. The 2D formula only works on a flat graph.