Slope & Distance Calculator (Two Points)

Find the slope, y-intercept, equation and angle of the line through two points — with the line drawn, plus the distance, midpoint and perpendicular slope.

Examples:

The line

Δx = 2Δy = 4
Equation:  y = 2x
Standard form (Ax + By = C):  2x - y = 0
Slope (m):  2
Slope as a fraction (rise/run):  2/1
Y-intercept (b):  0
X-intercept:  0
Angle:  63.434949°
Grade:  200%
Ratio (rise : run):  2 : 1
Rise (y₂ − y₁):  4
Run (x₂ − x₁):  2
Distance between the points:  4.472136
Manhattan distance:  6
Midpoint:  (1, 2)
Parallel slope:  2
Perpendicular slope:  -0.5

Manhattan distance is the trip along a grid — only horizontal and vertical moves, like walking city blocks: |x₂ − x₁| + |y₂ − y₁|. It is never shorter than the straight line.

Working

1. Rise: Δy = y₂ − y₁ = 4 − 0 = 4
2. Run: Δx = x₂ − x₁ = 2 − 0 = 2
3. Slope: m = Δy / Δx = 4 / 2 = 2
4. Y-intercept: b = y₁ − m·x₁ = 0 − 2 × 0 = 0
5. Angle: θ = atan(m) = atan(2) = 63.434949°
6. Grade: m × 100% = 2 × 100% = 200%
7. Distance: d = √(Δx² + Δy²) = √(2² + 4²) = 4.472136

The line through two points, drawn

Type the two coordinates and the tool gives the slope, the y-intercept, the equation in y = mx + b form and the angle the line makes with the horizontal. It also draws the line: both points marked, the midpoint ringed, and the axes shown wherever they fall inside the view. The picture is where a coordinate typed into the wrong box shows up.

Everything else two points tell you

Underneath are the rise and the run the slope is made of, the straight-line distance between the points, the midpoint, and the slopes of the lines parallel and perpendicular to this one. A horizontal line’s perpendicular is vertical, which has no slope at all — the page says so rather than printing infinity, because an undefined slope is not an infinite one.

Vertical lines, and empty boxes

When both points share an x the line is vertical: it has no slope and no y-intercept, so the equation is written as x = a number and the angle is 90°. It is still drawn. An empty coordinate box is not read as zero — the page names the box instead, because quietly computing a line through a point you never gave is a wrong answer with no warning attached.

Frequently asked questions

How is slope calculated from two points?

Slope m = (y₂ − y₁) ÷ (x₂ − x₁) — the rise over the run. The y-intercept then follows from b = y₁ − m·x₁, and the equation is y = mx + b. Both the rise and the run are shown separately so the division can be checked.

What is the slope of a perpendicular line?

The negative reciprocal, −1 ÷ m: a line of slope 2 is perpendicular to one of slope −0.5. The exception is a horizontal line, whose perpendicular is vertical and has no slope — the page says that in words rather than printing a number that would be wrong.

Why does a vertical line have no slope?

Because the run is zero and you cannot divide by it. The line still exists and is still drawn; it is written as x = a number, and its angle of inclination is 90°.

Does it give the distance and midpoint too?

Yes, both. The distance is √((x₂ − x₁)² + (y₂ − y₁)²) and the midpoint is the average of the two coordinates, ringed on the graph so it is clear which point it is.

Can I get the slope as a percentage grade, or start from a point and a slope?

Yes. The grade is shown as a percent beside the angle, a switch lets you enter a point and a slope instead of two points, and the working is printed step by step with your own numbers.

Can I get the slope as a fraction, the x-intercept, or the standard form?

Yes. Under the equation is the “Standard form (Ax + By = C)”, in whole numbers wherever the points allow it, and under the slope is the “Slope as a fraction (rise/run)” — or “not a short fraction” when it is not one, rather than a nearby fraction. The “X-intercept” follows the y-intercept.

How do I find the slope of a hill, a roof or a ramp?

Measure the rise — how far it climbs — and the run — how far along it goes — in the same unit; the slope is rise ÷ run. A road sign gives it as a percentage grade, rise ÷ run × 100, so climbing 1 m in 20 m is a 5% grade; a builder gives it as a ratio, which this page prints as “Ratio (rise : run)” — 1 : 20 for that ramp; and in the US a roof pitch is the rise per 12 of run, so a 6/12 roof has a slope of 0.5 and an angle of about 26.57°. Enter the foot of the slope as (0, 0) and the top as (run, rise), and the slope, the grade, the ratio and the angle all come out at once.

Can it show the slope as a ratio, the way a builder writes it?

Yes. “Ratio (rise : run)”, under the grade, writes the slope with a 1 on the smaller side — a gentle ramp reads 1 : 20 and a steep line 3 : 1 rather than 1 : 0.333333 — without a sign, since a ratio says how steep and not which way. A flat line reads “none (no rise)”, a vertical one is undefined, and the ratio goes into the copied result with everything else.