Formulas
- Distance: |AB| = √((x₂ − x₁)² + (y₂ − y₁)²) — the Pythagorean theorem.
- Midpoint: ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2).
- Slope: m = (y₂ − y₁) ÷ (x₂ − x₁), and the line is y = mx + b.
Example: A(1, 2) and B(4, 6)
Δx = 3 and Δy = 4, so |AB| = √(9 + 16) = 5. The midpoint is (2.5, 4), the slope 4 ÷ 3 ≈ 1.333 and the line y = 1.333x + 0.667.
Frequently asked questions
How do I find distance in 3D?
Add the third coordinate: √(Δx² + Δy² + Δz²).
Can I use this for map coordinates?
Not for latitude and longitude — you need to allow for the Earth's curvature, for example with the haversine formula.