Logo

MonoCalc

/

Distance Between Two Points

Geometry

Coordinate Mode

Point A

X₁

Y₁

Point B

X₂

Y₂

AB

Euclidean Distance

5

Manhattan Distance

7

Midpoint

(2.5, 4)

Slope

1.3333

About This Tool

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.

Frequently Asked Questions

Is the Distance Between Two Points free?

Yes, Distance Between Two Points is totally free :)

Can I use the Distance Between Two Points offline?

Yes, you can install the webapp as PWA.

Is it safe to use Distance Between Two Points?

Yes, any data related to Distance Between Two Points only stored in your browser (if storage required). You can simply clear browser cache to clear all the stored data. We do not store any data on server.

How does this distance between two points calculator work?

Enter the X and Y coordinates of two points (or X, Y, Z in 3D mode). The calculator instantly computes the Euclidean (straight-line) distance using the Pythagorean theorem: d = √((x₂−x₁)² + (y₂−y₁)²). Toggle to 3D mode to include a Z-axis. Results update in real time as you type.

What is the formula for the distance between two points?

In 2D: d = √((x₂−x₁)² + (y₂−y₁)²). In 3D: d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²). These formulas are derived directly from the Pythagorean theorem applied to the horizontal and vertical (and depth) separations between the two points.

What is Manhattan distance and when is it useful?

Manhattan distance (also called city-block or taxicab distance) is the sum of the absolute differences of coordinates: |x₂−x₁| + |y₂−y₁|. It represents the distance you would travel if you could only move along grid lines — horizontally or vertically — rather than in a straight line. It is commonly used in grid-based pathfinding, image processing, and urban planning.

What is a midpoint and how is it calculated?

The midpoint is the point exactly halfway between two points, calculated as M = ((x₁+x₂)/2, (y₁+y₂)/2). It lies on the line segment connecting the two points and divides it into two equal halves. In 3D mode the midpoint also includes a Z component: ((z₁+z₂)/2).

What does 'undefined slope' mean?

The slope of a line through two points is m = (y₂−y₁)/(x₂−x₁). When x₁ = x₂ (both points share the same X coordinate), the denominator is zero, making the slope mathematically undefined. This corresponds to a perfectly vertical line. The calculator displays 'Undefined (vertical line)' in this case rather than throwing an error.

Can I enter negative or decimal coordinate values?

Yes. The calculator accepts any real number for coordinates — positive, negative, zero, and decimal values are all valid. Identical points (where distance equals zero) are also accepted as a valid input and simply return a result of 0.