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

Geometry
01

Calculation inputs

All lengths use the same arbitrary unit u; areas use u² and volumes use u³. Angles are in degrees.

Point A
Point B
03

Results

Solution state
Ordinary line
Δx
3
Δy
4
Midpoint
(1.5 ; 2)
Slope
1.333
Angle θ
53.13°

Results show up to four significant digits for readability; internal calculations retain full precision.

See calculation details

01Δx

FormulaΔx = x₂ − x₁
Substitution3 − 0
Result
3

02Δy

FormulaΔy = y₂ − y₁
Substitution4 − 0
Result
4

03Distance AB

Formulad = √(Δx² + Δy²)
Substitution√(3² + 4²)
Result
5

04Midpoint

FormulaM = ((x₁ + x₂)/2 ; (y₁ + y₂)/2)
Substitution((0 + 3)/2 ; (0 + 4)/2)
Result
(1.5 ; 2)

05Slope

Formulam = Δy/Δx
Substitution4 / 3
Result
1.333

06b

Formulab = y₁ − mx₁
Substitution0 − 1.333 × 0
Result
0

07Equation

Formulay = mx + b
Substitution1.333 × x + 0
Result
y = 1.333x

08Angle θ

Formulaθ = atan2(Δy, Δx)
Substitutionatan2(4 ; 3) × 180°/π
Result
53.13
01Formulas and symbols

Formulas used

d

d = √((x₂−x₁)²+(y₂−y₁)²)

M = ((x₁+x₂)/2,(y₁+y₂)/2)

d: distance AB; M: midpoint of segment AB.

m

m = (y₂−y₁)/(x₂−x₁)

m: line slope; Δx and Δy: coordinate differences.

SymbolMeaning
x₁Point A — x₁
y₁Point A — y₁
x₂Point B — x₂
y₂Point B — y₂
ΔxΔx
ΔyΔy
dDistance AB
MMidpoint
mSlope
θAngle θ
ℓEquation
02Validation example

Reference numerical case

  1. 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₁.

07Technical references