Home › Math › Distance Between Two Points Calculator
Distance Between Two Points Calculator
Computes the straight-line (Euclidean) distance between two points in the plane, their midpoint, the coordinate differences and the Manhattan distance.
When to use
You have two (x, y) coordinates and need the distance between them or the point halfway between them.
Do not use when: You need the slope or equation of the line through the points (use slope) or the third side of a right triangle from two sides (use pythagorean).
Formula
distance = √((x₂ − x₁)² + (y₂ − y₁)²); midpoint = ((x₁ + x₂)/2, (y₁ + y₂)/2); manhattan = |x₂ − x₁| + |y₂ − y₁|
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
x1 | number | yes | x-coordinate of the first point. | |
y1 | number | yes | y-coordinate of the first point. | |
x2 | number | yes | x-coordinate of the second point. | |
y2 | number | yes | y-coordinate of the second point. |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
distance | number | √((x₂ − x₁)² + (y₂ − y₁)²). | |
midpoint_x | number | (x₁ + x₂) / 2. | |
midpoint_y | number | (y₁ + y₂) / 2. | |
midpoint | string | The midpoint as a coordinate pair, e.g. '(2, 4)'. | |
delta_x | number | x₂ − x₁. | |
delta_y | number | y₂ − y₁. | |
manhattan_distance | number | |Δx| + |Δy|: the grid (taxicab) distance. |
Example
(0, 0) to (3, 4): {"x1":0,"y1":0,"x2":3,"y2":4} → {"distance":5,"midpoint_x":1.5,"midpoint_y":2,"midpoint":"(1.5, 2)","delta_x":3,"delta_y":4,"manhattan_distance":7}
(1, 2) to (4, 6): {"x1":1,"y1":2,"x2":4,"y2":6} → {"distance":5,"midpoint_x":2.5,"midpoint_y":4,"midpoint":"(2.5, 4)","manhattan_distance":7}
GET https://tttkmbb.com/api/v1/calculate/distance-2d?x1=0&y1=0&x2=3&y2=4
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/distance-2d(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/distance-2d · Markdown: https://tttkmbb.com/math/distance-2d.md · JSON definition: https://tttkmbb.com/math/distance-2d.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="distance-2d" - OpenAPI operationId:
calculate_distance_2d - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- Wikipedia – Euclidean distance (reference)
- Wikipedia – Midpoint (reference)
- Wolfram MathWorld – Distance (reference)
FAQ
Does the order of the points matter?
Not for the distance or midpoint. Δx and Δy are signed (second minus first), so they flip sign if the points are swapped.
Can I use this for GPS coordinates?
Only for very short distances. Latitude/longitude lie on a sphere; use the haversine formula for geographic distances.
Related calculators
- Slope Calculator — Slope and equation of the line through the points.
- Pythagorean Theorem Calculator — The distance formula is the Pythagorean theorem applied to Δx and Δy.
- Right Triangle Calculator — Full right-triangle solver.