# 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.

- Calculator id: `distance-2d` · Category: Math (`math`) · Tool name: `calculate_distance_2d`
- Canonical page: https://tttkmbb.com/math/distance-2d · This document: https://tttkmbb.com/math/distance-2d.md · JSON definition: https://tttkmbb.com/math/distance-2d.json

## Purpose

Computes the straight-line (Euclidean) distance between two points in the plane, their midpoint, the coordinate differences and the Manhattan distance.

**Use when:** 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).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `x1` | number |  | required | x-coordinate of the first point. |
| `y1` | number |  | required | y-coordinate of the first point. |
| `x2` | number |  | required | x-coordinate of the second point. |
| `y2` | number |  | required | y-coordinate of the second point. |

## Output

| Field | 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. |

## Formula

`distance = √((x₂ − x₁)² + (y₂ − y₁)²); midpoint = ((x₁ + x₂)/2, (y₁ + y₂)/2); manhattan = |x₂ − x₁| + |y₂ − y₁|`

## Data Sources

- Wikipedia – Euclidean distance — https://en.wikipedia.org/wiki/Euclidean_distance (reference, retrieved 2026-09-23)
- Wikipedia – Midpoint — https://en.wikipedia.org/wiki/Midpoint (reference, retrieved 2026-09-23)
- Wolfram MathWorld – Distance — https://mathworld.wolfram.com/Distance.html (reference, retrieved 2026-09-23)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/distance-2d?x1=…&y1=…&x2=…&y2=…`
- `POST https://tttkmbb.com/api/v1/calculate/distance-2d` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/distance-2d · OpenAPI operationId `calculate_distance_2d` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "distance-2d", "inputs": {…}}`

## Example

- (0, 0) to (3, 4): inputs `{"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): inputs `{"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
```

## Limitations

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). All values are computed from the formula above; no measurement or live data is involved.

## 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

- [Slope Calculator](https://tttkmbb.com/math/slope.md) — Slope and equation of the line through the points.
- [Pythagorean Theorem Calculator](https://tttkmbb.com/math/pythagorean.md) — The distance formula is the Pythagorean theorem applied to Δx and Δy.
- [Right Triangle Calculator](https://tttkmbb.com/geometry/right-triangle.md) — Full right-triangle solver.
