Math
Distance Formula Calculator
Find the distance between two points in 2D or 3D space, or sum a polyline path. Built on the Pythagorean theorem.
Choose a mode
Point 1 (x1, y1)
Point 2 (x2, y2)
Distance
5
2D space
dx
3
dy
4
Frequently Asked Questions about the Distance Formula Calculator
What is the distance formula?
The distance formula derives from the Pythagorean theorem: d = sqrt((x2 - x1)^2 + (y2 - y1)^2). The horizontal and vertical differences form the two legs of a right triangle, and the distance between the points is the hypotenuse. For example, from (1, 2) to (4, 6) the legs are 3 and 4, giving d = sqrt(9 + 16) = 5.
How do you extend the formula to 3D?
Add a z-axis term: d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2). This applies the same Pythagorean logic twice, first across the horizontal plane, then up into the third dimension.
What does polyline mode calculate?
Polyline mode sums the straight-line distances between every pair of consecutive points in the order you enter them, giving the total path length through all vertices. You can mix 2D and 3D points; any point without a z coordinate is treated as z = 0.
Does the order of the two points matter?
No. Both differences are squared before being summed, so swapping point A and point B produces the same distance.
Can the result be negative?
No. Squaring each difference eliminates negative signs, and the square root of a non-negative number is always non-negative. The result is zero only when both points are identical, and positive in every other case.