Advertisement

Euclidean distance calculator

Enter coordinate lists of equal length, or choose a two-dimensional line calculation. All coordinates must share one scale.

Calculator

Distance (points 1-2 or perpendicular gap)
5.00000000
Coordinate contributions
PairAxisDifferenceSquared difference
1-2x3.000000009.00000000
1-2y4.0000000016.00000000

Advertisement

How this calculator works

Subtract matching coordinates, square the differences and add them. The square root gives the straight Euclidean gap. The component table separates each axis and, with three points, each pair. The two-segment path usually exceeds the direct first-to-third distance. A line calculation instead projects onto the unit normal (A,B)/hypot(A,B), giving both the perpendicular gap and its foot. Parallel lines must be written with exactly the same A and B before their constants can be compared.

Formula

d(P,Q) = sqrt(Σ(Qᵢ-Pᵢ)²). For Ax+By+C=0, d = |Ax₀+By₀+C|/sqrt(A²+B²). For parallel lines with the same A,B, d = |C₂-C₁|/sqrt(A²+B²).

Worked example

The four-dimensional points (0,0,0,0) and (1,2,2,4) differ by squared contributions 1, 4, 4 and 16. Their distance is √25 = 5. The origin is 2 units from 3x+4y-10=0, with perpendicular foot (1.2,1.6).

Advertisement

Frequently asked questions

What does the fourth coordinate mean?

It can be any fourth perpendicular coordinate, often written w. For data features, choose compatible scaling before interpreting the distance.

Can a vertical line be entered?

Yes. For x=2 use A=1, B=0 and C=-2. A and B cannot both be zero.

Why do my point lists need equal lengths?

Every coordinate must be paired with the same axis in the other point. A missing coordinate cannot be assumed to be zero.

Is this suitable for longitude and latitude?

Those are angular coordinates on a curved surface. Use a geographic distance model or project them to suitable Cartesian coordinates first.

Sources

Advertisement