Mathematics · Geometry
Coordinate geometry calculator — distance, midpoint and line
Find distance, midpoint, slope and line equation between two 2D points, with explicit vertical-line and identical-point states.
Created v1.0
By Thibaut Grzelak, Mechanical Analysis Engineer
Results
Euclidean segment length.
Equation of the resulting line.
Results show up to four significant digits for readability; internal calculations retain full precision.
See calculation details
01Δx
Δx = x₂ − x₁3 − 002Δy
Δy = y₂ − y₁4 − 003Distance AB
d = √(Δx² + Δy²)√(3² + 4²)04Midpoint
M = ((x₁ + x₂)/2 ; (y₁ + y₂)/2)((0 + 3)/2 ; (0 + 4)/2)05Slope
m = Δy/Δx4 / 306b
b = y₁ − mx₁0 − 1.333 × 007Equation
y = mx + b1.333 × x + 008Angle θ
θ = atan2(Δy, Δx)atan2(4 ; 3) × 180°/π01Formulas and symbols
Formulas used
d = √((x₂−x₁)²+(y₂−y₁)²)
M = ((x₁+x₂)/2,(y₁+y₂)/2)
d: distance AB; M: midpoint of segment AB.
m = (y₂−y₁)/(x₂−x₁)
m: line slope; Δx and Δy: coordinate differences.
| Symbol | Meaning |
|---|---|
| x₁ | Point A — x₁ |
| y₁ | Point A — y₁ |
| x₂ | Point B — x₂ |
| y₂ | Point B — y₂ |
| Δx | Δx |
| Δy | Δy |
| d | Distance AB |
| M | Midpoint |
| m | Slope |
| θ | Angle θ |
| ℓ | Equation |
02Validation example
Reference numerical case
- A = (0, 0), B = (3, 4): distance 5 u, midpoint (1.5, 2), slope 4/3. Points (2, 1) and (2, 5) define the vertical line x = 2.
03How it works
Distance is the length of segment AB; the midpoint averages each coordinate. The slope divides Δy by Δx. The directed segment angle uses atan2 and is measured from the positive x-axis in degrees.
The slope is the vertical change divided by the horizontal change. When x₂ = x₁, this division is undefined and the line is vertical.
04Limits and conventions
Cartesian coordinates in a common unit, with equal scales on x and y. Identical points do not define a unique line. A vertical line has equation x = x₁ and undefined slope.
05Common mistakes
An undefined slope does not mean zero slope. The midpoint is a point, not half the distance.
06Practical questions
Why is the slope undefined for a vertical line?
Slope is Δy/Δx. For a vertical line, Δx = 0, so the division is undefined even though the line itself is valid and can be written x = constant.
How do you find the equation of a line from two points?
For two distinct nonvertical points, compute m = (y₂ − y₁)/(x₂ − x₁), then use y − y₁ = m(x − x₁). If x₁ = x₂, the line is vertical and its equation is x = x₁.