Distance formula calculator for 2D and 3D points
Enter two coordinate points and choose 2D or 3D. HitEquals reports straight-line distance, coordinate differences, squared distance and the midpoint.
Inputs used by this calculator
Distance Calculator uses the fields below. The starting values reproduce the page example; replace them with values from the same units and time period before using the result.
| Input | Starting example | Accepted value | How it is used |
|---|---|---|---|
| Coordinate space | 2D — x and y | 2D — x and y · 3D — x, y and z | Supplies the coordinate space quantity used by the published equation or result breakdown. |
| First point x₁ | 2 | Any finite number supported by the formula | Supplies the first point x₁ quantity used by the published equation or result breakdown. |
| First point y₁ | 1 | Any finite number supported by the formula | Supplies the first point y₁ quantity used by the published equation or result breakdown. |
| First point z₁ | 0 | Any finite number supported by the formula | Supplies the first point z₁ quantity used by the published equation or result breakdown. |
| Second point x₂ | 6 | Any finite number supported by the formula | Supplies the second point x₂ quantity used by the published equation or result breakdown. |
| Second point y₂ | 4 | Any finite number supported by the formula | Supplies the second point y₂ quantity used by the published equation or result breakdown. |
| Second point z₂ | 0 | Any finite number supported by the formula | Supplies the second point z₂ quantity used by the published equation or result breakdown. |
Distance between two points
Subtract matching coordinates, square each difference, add the squares and take the positive square root. Squaring removes direction, so reversing the two points gives the same distance.
Distance formula
The 2D formula follows from the Pythagorean theorem. Three dimensions add the squared z difference.
d₂D = √((x₂−x₁)² + (y₂−y₁)²)d₃D = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²)Midpoint
Average each coordinate separately. The midpoint lies halfway along the segment and is shown with the result.
midpoint = ((x₁+x₂)/2, (y₁+y₂)/2, (z₁+z₂)/2)Units and coordinate systems
The answer uses coordinate units. Do not mix feet and meters or coordinates from different map projections without converting them first.
Worked example
For (2,1) and (6,4), the changes are 4 and 3. Their squared sum is 25, so distance is 5 and midpoint is (4,2.5).
Straight-line distance versus route distance
Coordinate distance connects two points with one straight segment. It does not follow streets, terrain or the curved surface of Earth. Driving, walking and geographic distance require route or geodesic data rather than this Cartesian formula.
How to verify coordinate inputs
Confirm that both points use the same axis order, scale and origin. A swapped x/y coordinate or a mix of feet and meters can produce a valid-looking number for the wrong geometry.
- Write each point in the same coordinate order.
- Subtract matching coordinates.
- Check the squared differences shown in the result.
- Recalculate the midpoint by averaging each pair.
Distance workflow
| Step | 2D operation |
|---|---|
| Differences | Δx=x₂−x₁; Δy=y₂−y₁ |
| Squared distance | Δx²+Δy² |
| Distance | positive square root |
| Midpoint | average each coordinate |
Distance formulas by setting
| Setting | Known values | Relationship |
|---|---|---|
| Number line | x₁, x₂ | |x₂−x₁| |
| 2D Cartesian | x and y pairs | √(Δx²+Δy²) |
| 3D Cartesian | x, y and z pairs | √(Δx²+Δy²+Δz²) |
| Road or trail | network path | Route calculation required |
| Earth surface | latitude/longitude | Geodesic model required |
Frequently asked questions
What is the distance formula?
It is the square root of the sum of squared coordinate differences.
Can distance be negative?
No. Geometric distance is the nonnegative length of the segment.
Does point order matter?
No. Reversing the points changes difference signs but not their squares.
How does 3D distance work?
It adds the squared z-coordinate difference before taking the square root.
Does this calculate driving distance?
No. It calculates straight-line coordinate distance, not a route on roads.
Can I use latitude and longitude directly?
Not for reliable surface distance. Geographic coordinates require a spherical or ellipsoidal Earth model.
Why is the midpoint useful?
It identifies the point halfway along the straight segment in the same coordinate system.
What to keep in mind
Coordinates must use the same scale and reference system. In 2D mode, z values are ignored.
Results are rounded for display in US format, with money in dollars and cents; CSV exports keep full calculation precision. This is a calculation summary, not an official certificate.