Distance Between Two Points

The distance between two points comes from the Pythagorean theorem.

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

The differences in x and y are the legs of a right triangle; the distance is the hypotenuse.

In 3D, add (z₂ − z₁)² before taking the square root.

Calculator

Change a value and the result and picture update instantly.

Result

Distance d5

Animated picture

The picture follows your values. Some points and shapes can be dragged.

Use in game development

If you only need to compare distances, compare the squares and skip the square root — it is faster.

Code example (JavaScript)

const near = dx*dx + dy*dy < range*range; // skip sqrt for comparisons

What the symbols mean

SymbolMeaning
x1x₁
y1y₁
x2x₂
y2y₂
dDistance d

More formulas in this category

Frequently asked questions

What is the formula for Distance Between Two Points?
The formula for Distance Between Two Points is d = √((x₂ − x₁)² + (y₂ − y₁)²). The distance between two points comes from the Pythagorean theorem.

Math Formula Quiz Coordinate Geometry

Sources

Checked: 2026-11-29