Distance Calculator

Calculate the straight-line (Euclidean) distance between two points in 2D or 3D space using the distance formula. Also finds the midpoint and slope of the line segment.

Distance Formula

2D: d = √((x₂−x₁)² + (y₂−y₁)²)
3D: d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²)
Midpoint: M = ((x₁+x₂)/2, (y₁+y₂)/2)

Example

Points A(3, 4) and B(7, 1)

d = √((7−3)² + (1−4)²) = √(16 + 9) = √25 = 5

Midpoint = ((3+7)/2, (4+1)/2) = (5, 2.5)

Slope = (1−4)/(7−3) = −3/4 = −0.75

Distance Formula Applications

ApplicationWhat it finds
GPS / navigationStraight-line distance between coordinates
Computer graphicsPixel distance, collision detection
PhysicsDisplacement between two positions
Data scienceEuclidean distance in feature space (kNN)
EngineeringLength of structural members from endpoints

Frequently Asked Questions

What is the difference between distance and displacement?

Distance is the total path length traveled (scalar, always positive). Displacement is the straight-line distance from start to end with direction (vector). This calculator computes straight-line Euclidean distance — equivalent to displacement magnitude.

What is Manhattan distance?

Manhattan (or taxicab) distance = |x₂−x₁| + |y₂−y₁|. It measures distance along grid lines (like city blocks) rather than straight lines. It is used in machine learning and grid-based pathfinding algorithms. This calculator computes Euclidean (straight-line) distance.

How do I find the distance between GPS coordinates?

For GPS coordinates (latitude/longitude), use the Haversine formula, which accounts for Earth's curvature. The flat-plane distance formula only works for small local distances where curvature is negligible. For large distances between cities, the Haversine result differs significantly from flat-plane Euclidean distance.

Related Calculators