Distance Formula Calculator
Enter the coordinates of two points to get the straight-line distance between them, in two or three dimensions.
Formula
3D: d = √(Δx2 + Δy2 + Δz2)
| Symbol | Meaning |
|---|---|
| (x₁, y₁, z₁) | Coordinates of the first point |
| (x₂, y₂, z₂) | Coordinates of the second point |
| d | Straight-line distance between the points |
How to Use This Calculator
- Choose the Dimensions (2D (x, y), 3D (x, y, z)).
- Enter the x₁.
- Enter the y₁.
- Enter the z₁ when Dimensions is 3D (x, y, z).
- Enter the x₂.
- Enter the y₂.
- Enter the z₂ when Dimensions is 3D (x, y, z).
- Press Calculate. Results also update automatically as you type.
Worked Example
Using the values pre-filled in the calculator above:
| Dimensions | 2D (x, y) |
|---|---|
| x₁ | 1 |
| y₁ | 2 |
| x₂ | 7 |
| y₂ | 10 |
| Distance | 10 |
|---|---|
| Distance squared | 100 |
| Working | √(6² + 8²) = √100 |
About This Calculation
The distance formula is the Pythagorean theorem written in coordinates. The horizontal gap Δx and the vertical gap Δy between two points form the legs of a right triangle, and the straight line joining the points is its hypotenuse. In three dimensions the same idea is applied twice, adding a Δz² term under the square root.
Because the differences are squared, it does not matter which point you call the first: the distance from A to B equals the distance from B to A, and negative coordinates are handled automatically. The result is in the same units as the coordinates, so if your axes are in meters, so is the distance. On a map with latitude and longitude, however, this formula is only an approximation over short ranges — for long distances on the curved Earth you need the great-circle (haversine) formula.
Euclidean distance is used in computer graphics and game collision checks, in GPS and robotics, in CAD and surveying, and in data science, where algorithms such as k-nearest neighbors and k-means clustering measure how "close" two data points are. The squared distance is shown too, since programs often compare squared distances to avoid the cost of a square root.
Frequently Asked Questions
- Can the distance ever be negative?
- No. It is the square root of a sum of squares, so it is always zero or positive. It is zero only when both points are identical.
- What is the midpoint of the same two points?
- Average the coordinates: ((x₁ + x₂)/2, (y₁ + y₂)/2). The midpoint calculator does this and also shows the segment length.