Math · Coordinate Geometry
Distance
Calculator
Calculate distance between two points in 2D or 3D, find great-circle distance from latitude/longitude, or sum multi-point path distances — with coordinate graph and step-by-step solutions.
—
Distance
—
Midpoint
2D
Mode
2D Distance Between Two Points
P₁
x₁
y₁
P₂
x₂
y₂
3D Distance Between Two Points
P₁
x₁
y₁
z₁
P₂
x₂
y₂
z₂
Great-Circle Distance (Haversine)
Enter decimal degrees (−90 to 90 lat, −180 to 180 lon). Positive = North/East.
📍A
Lat
Lon
📍B
Lat
Lon
Multi-Point Path Distance
Sum of all consecutive 2D distances along a path of waypoints.
Distance
—
units
Alt. Unit
—
Midpoint
—
Distance
—
Midpoint
—
Δx / Δy
—
Angle
—
Distance & Properties
📈 Coordinate Plane
Distance Formulas
The distance between two points comes from the Pythagorean theorem: the horizontal and vertical separations form the legs of a right triangle, and the distance is the hypotenuse.
Key Formulas
2D Distance: d = √((x₂−x₁)² + (y₂−y₁)²)
3D Distance: d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²)
Midpoint 2D: ((x₁+x₂)/2, (y₁+y₂)/2)
Midpoint 3D: ((x₁+x₂)/2, (y₁+y₂)/2, (z₁+z₂)/2)
Haversine: a = sin²(Δφ/2) + cosφ₁·cosφ₂·sin²(Δλ/2)
d = 2R·arcsin(√a) [R = 6371 km]
Slope: m = (y₂−y₁)/(x₂−x₁)
Angle: θ = arctan((y₂−y₁)/(x₂−x₁))
Why does the distance formula use square root?
The distance formula is the Pythagorean theorem in coordinate form. If you draw a right triangle with P₁ and P₂ as the hypotenuse endpoints, the legs are |x₂−x₁| (horizontal) and |y₂−y₁| (vertical). Pythagorean theorem: d² = Δx² + Δy², so d = √(Δx² + Δy²). This extends to 3D by adding a third leg: d = √(Δx² + Δy² + Δz²). It extends to n dimensions the same way.
What is the Haversine formula and why is it used?
The Haversine formula calculates the great-circle distance between two points on a sphere — the shortest path along the Earth's curved surface. It's numerically stable for small distances where simpler spherical law of cosines formulas lose precision. The Earth's radius used is 6371 km (mean radius). Note: it assumes a perfect sphere — actual Earth distances vary by up to 0.5% due to the oblong shape. For navigation, the Vincenty formula is more accurate.
What is the difference between Euclidean and Manhattan distance?
Euclidean distance is the straight-line ("as the crow flies") distance: √(Δx²+Δy²). Manhattan distance (taxicab distance) is |Δx| + |Δy| — the distance you'd travel on a grid city, moving only horizontally and vertically (like Manhattan's street grid). Euclidean is ≤ Manhattan, with equality only when movement is in one direction. Manhattan distance is used in machine learning, routing algorithms, and any grid-based problem. Chess "king moves" use Chebyshev distance: max(|Δx|, |Δy|).
How do you find the distance from a point to a line?
For a line Ax + By + C = 0 and point (x₀, y₀): distance = |Ax₀ + By₀ + C| / √(A² + B²). For slope-intercept form y = mx + b, rewrite as mx − y + b = 0 (A=m, B=−1, C=b): distance = |mx₀ − y₀ + b| / √(m²+1). This gives the perpendicular (shortest) distance from the point to the line. The foot of the perpendicular is the closest point on the line.