Distance Between Two Points Calculator
Distance between two points from their coordinates, in the plane and in space. Midpoint, coordinate differences, slope and direction angle, with working.
How do you find the distance between two points?
The distance between two points with known coordinates comes from the Pythagorean theorem. The difference in x and the difference in y are the legs of a right triangle, and the distance you want is its hypotenuse: d = √((x₂ − x₁)² + (y₂ − y₁)²).
Because the differences are squared, the order of the points does not matter and negative coordinates cause no trouble.
Distance in space (three dimensions)
A third axis adds one more term: d = √(Δx² + Δy² + Δz²). If z is height, the square root of the first two terms is the horizontal distance and the square root of all three is the sloping distance.
Example
For A(1, 2) and B(4, 6), Δx = 3 and Δy = 4. The distance is √(9 + 16) = √25 = 5 units. The midpoint is ((1 + 4) / 2, (2 + 6) / 2) = (2.5, 4) and the slope of the line is 4 / 3 = 1.333.
In space, A(1, 2, 3) and B(4, 6, 15) differ by 3, 4 and 12, so the distance is √(9 + 16 + 144) = 13 units.
Midpoint, slope and direction angle
The midpoint is the average of the coordinates. The slope is the difference in y divided by the difference in x: when the x difference is zero the line is vertical and the slope is undefined. The direction angle is measured from the +x axis to the direction from the first point to the second.
Use on site
The diagonal between two grid intersections on a setting out sketch, the spacing between two anchor holes, or the cut length of a pipe from the coordinates of its two ends all come from this calculation. The coordinates only need to share one unit and one origin.
Limits
The calculator is for points in a flat coordinate system. The distance between two places given by latitude and longitude cannot be found with this formula.
Related calculators
-
Geometry
3D Distance and Vector Calculator
Distance and vector between two points in space, midpoint, vector magnitude, unit vector, direction cosines and the angles with the axes. -
Geometry
Line Equation Calculator
Equation of a line from two points or from a point and a slope: y = mx + n, general form ax + by + c = 0, slope angle and axis intercepts. -
Geometry
Angle from Three Points Calculator
The angle formed at the vertex by three points given as coordinates, in the plane and in space. Also gives the other angles, sides and area of the triangle. -
Geometry
Polygon and Land Area from Coordinates Calculator
Polygon area from corner coordinates in square metres, decares and hectares. Perimeter, side lengths, centroid and a sketch. Paste a list or load a CSV file.
Found a mistake or something missing?
If a value looks wrong, a size is missing or you need a feature, write to us and we will fix it.