Distance Between Two Points Calculator
The distance between two points is the length of the straight line segment connecting them, measured in the same units as the coordinate values. This calculator computes that distance instantly for both two-dimensional (2D) and three-dimensional (3D) coordinate spaces, along with the midpoint, slope, and Manhattan distance.
The Euclidean Distance Formula
The standard straight-line distance formula is derived from the Pythagorean theorem. For two points A(x₁, y₁) and B(x₂, y₂) in a plane:
d = √((x₂ − x₁)² + (y₂ − y₁)²)
The horizontal separation (x₂ − x₁) and vertical separation (y₂ − y₁) form the two legs of a right triangle; the distance is the hypotenuse. In 3D space, a depth component is added:
d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
This generalisation works identically — three coordinate differences squared and summed under a single square root.
Midpoint of a Line Segment
The midpoint lies exactly halfway between two points. Its coordinates are the arithmetic averages of the corresponding coordinates:
M = ((x₁ + x₂) / 2, (y₁ + y₂) / 2)
Midpoints appear frequently in geometry proofs, computer graphics (bisecting edges of meshes), and GPS route planning (finding a meeting point halfway between two locations).
Slope of the Line
In 2D mode the calculator also reports the slope (gradient) of the line passing through the two points:
m = (y₂ − y₁) / (x₂ − x₁)
A positive slope means the line rises left-to-right; a negative slope means it falls. When x₁ = x₂ the line is perfectly vertical and the slope is mathematically undefined — the calculator displays Undefined (vertical line) rather than returning an error.
Manhattan Distance
The Manhattan distance (also called taxicab or city-block distance) counts how far you would travel if restricted to axis-aligned movements — like navigating streets in a grid city:
d_manhattan = |x₂ − x₁| + |y₂ − y₁|
Manhattan distance is always greater than or equal to the Euclidean distance. It is widely used in machine learning distance metrics (k-nearest neighbours), robotics path planning, and image processing (pixel neighbourhood calculations).
Common Applications
Computing the distance between two points arises in many fields. In game development, distance checks determine collision detection, aggro ranges, and pathfinding. In GIS and mapping, the formula converts projected coordinate differences into on-screen or approximate on-ground distances. In physics and engineering, it measures displacement between two positions in space. Students encounter the formula in analytic geometry, trigonometry, and pre-calculus courses.
How to Use This Calculator
Select 2D or 3D mode using the toggle at the top. Enter the coordinates for Point A and Point B in the respective fields — the calculator accepts any real number including negatives and decimals. Results update instantly as you type. Use the Show Steps button to reveal the full substituted formula. The Copy Distance button places the Euclidean distance on your clipboard, and individual copy buttons sit beside each output row.
Accuracy and Limitations
All calculations use JavaScript's 64-bit floating-point arithmetic (IEEE 754 double precision), which provides about 15–16 significant decimal digits. For most practical purposes this is more than sufficient. The coordinate diagram shown in 2D mode is a scaled schematic — the axis origin and scale are normalised to the entered values and serve as a visual aid rather than an accurate coordinate grid.