Coordinate geometry calculator

Find distance, midpoint, slope, and the line through two points.

Point 1
Point 2
Assumptions & limits

Cartesian 2D coordinates in the same unit. Signed values up to ±10⁹. Nonzero differences in either coordinate must be at least 10⁻⁹. Identical points give zero distance but no unique line. Vertical lines have undefined slope, not infinity.

YOUR ANSWER

Distance

5 units

Midpoint
(1.5, 2)
Slope
1.3333
Line
y = 1.3333x + 0
How it’s calculatedCalculated on your device

Distance = √[(x₂ − x₁)² + (y₂ − y₁)²]. Midpoint = ((x₁ + x₂)/2, (y₁ + y₂)/2). Slope = (y₂ − y₁)/(x₂ − x₁).

Displayed values may be rounded. Calculations keep the underlying precision.

Coordinates are limited to ±10⁹. Nonzero differences must be at least 10⁻⁹ on each axis. Both axes use the same unit and scale. This is flat Cartesian geometry, not geographic latitude/longitude or a great-circle distance.

The formula, made simple

Enter two Cartesian points to find their straight-line distance, midpoint, slope, and line equation. Negative and decimal coordinates are supported.

Distance = √[(x₂ − x₁)² + (y₂ − y₁)²]. Midpoint = ((x₁ + x₂)/2, (y₁ + y₂)/2). Slope m = (y₂ − y₁)/(x₂ − x₁). For nonvertical lines, y = mx + b with b = y₁ − mx₁.

A worked example

Points (0, 0) and (3, 4) have distance 5, midpoint (1.5, 2), slope 4/3, and line y = (4/3)x. Points (2, 1) and (2, 5) instead define the vertical line x = 2.

A few useful answers

What is the slope of a vertical line?

It is undefined because its horizontal change is zero. The tool shows x = a constant, without displaying infinity.

What if both points are identical?

Distance is zero and the midpoint is that same point. Infinitely many lines can pass through it, so no unique line or slope is reported.

Back to calculator ↑