BL2.ru

Distance between two points in space (calculate online)

r = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²)
Point O1:
Point O2:

The calculator finds the distance between two points in space from their coordinates O1(x1, y1, z1) and O2(x2, y2, z2). The diagram above shows an example of points in space.

Formula

r = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)

It is the Pythagorean theorem applied twice: first the diagonal of the projection onto the XY plane, then the hypotenuse with the Z leg. On a plane (z₁ = z₂) it becomes the ordinary 2D distance.

Example

O1(1, 2, 3), O2(4, 6, 15). Differences: 4 − 1 = 3, 6 − 2 = 4, 15 − 3 = 12. r = √(9 + 16 + 144) = √169 = 13.

Good to know

  • The order of points does not matter: differences are squared, so the sign disappears.
  • Coordinates may be negative or fractional (dot or comma); an empty field counts as zero.
  • The result is in the same units as the coordinates. Do not mix units.
  • For latitude/longitude on the Earth this formula does not apply directly: convert to Cartesian (ECEF) first or use the haversine formula.

Where it is used

  • Games and 3D graphics — range to a target, area of effect, collisions, level of detail.
  • CAD — the length of a pipe, cable or beam between two nodes.
  • GPS and geodesy — distance between points in Cartesian coordinates including height.
  • Physics — displacement, the distance between charges in Coulomb's law or masses in the law of gravitation.
  • Chemistry and data analysis — bond lengths, Euclidean distance in clustering.

How to use

Enter x, y, z of both points and press “Calculate”. The result (with a copy button) and a 3D diagram appear below; “Reset” clears the fields.