Skip to content
AZ Tools

Slope & Line Calculator

From two points, get the slope, the line equation y = mx + b, the distance, midpoint, angle of inclination, and rise/run.

Point 1

xy

Point 2

xy
Line equation

y = 2x + 0

Slope (m)

2

Angle

63.43°

Distance

6.7082

Midpoint

(2.5, 5)

Rise (Δy)

6

Run (Δx)

3

How to use

  1. Enter the x and y coordinates of the first point.
  2. Enter the x and y coordinates of the second point.
  3. Read the slope, equation, distance, midpoint, angle and rise/run; copy the equation if you need it.

About this tool

Show

Give it two points and it works out everything the line through them implies: the slope as Δy over Δx, the equation in slope-intercept form, the angle of inclination, the straight-line distance, the midpoint, and the rise and run separately. A vertical line is handled rather than divided by zero — the slope comes back undefined and the equation as x equals a constant, which is correct and is the case most implementations forget.

Slope gets expressed three different ways in practice, and they are easy to confuse because all three sound like percentages of something. As a ratio it is rise over run. As an angle it is the arctangent of that ratio. As a grade it is the ratio times a hundred, and that last one is where the confusion lives: a 100 percent grade is not vertical, it is 45 degrees, because it means rising one unit for every unit travelled horizontally. A 10 percent road sign is 5.7 degrees, and an 8 percent grade is 4.6 — numbers that feel much smaller than the signs suggest.

Roofing uses a fourth convention, rise in inches per twelve inches of run. A 4:12 pitch is 18.4 degrees and a 6:12 is 26.6, which is why a roofer's "six twelve" and a surveyor's "twenty-six and a half degrees" describe the same roof without either of them converting.

The midpoint and distance are worth a note about what they assume. Both treat the plane as flat and the axes as having the same units, which is true on graph paper and not true of latitude and longitude — a degree of longitude is a different distance from a degree of latitude everywhere except the equator, so the distance between two coordinates is not the distance this returns. For geographic work the answer comes from a haversine or a geodesic calculation, not from Pythagoras on the raw degrees.

Frequently asked questions

How is the slope calculated?

Slope m = (y₂ − y₁) / (x₂ − x₁), the change in y divided by the change in x. For example, from (1, 2) to (4, 8) the slope is (8 − 2) / (4 − 1) = 2.

What happens with a vertical line?

If both points share the same x value, the run is zero and the slope is undefined — a vertical line. The equation is shown as x = that value, and the angle is 90°.

What is the angle of inclination?

It's the angle the line makes with the horizontal x-axis, equal to arctan(slope). A slope of 1 is 45°; a horizontal line is 0°.

How is the distance found?

By the distance formula √((x₂ − x₁)² + (y₂ − y₁)²) — the length of the straight segment between the two points.

What is the difference between slope, percent grade and degrees?

They describe the same steepness three ways. Slope is rise over run as a plain ratio, percent grade is that ratio times a hundred, and the angle is its arctangent. They diverge fast: a 100 percent grade is a slope of 1 and only 45 degrees, so a road sign reading 10 percent is about 5.7 degrees, not 10.

Why is a vertical line undefined rather than infinite?

Because the run is zero and dividing by zero has no value, not a very large one. A vertical line has no slope in the y = mx + b sense at all — it cannot be written in that form, only as x equals a constant. That is also why it is the one case a slope-intercept equation cannot express.

Related tools