Slope Calculator (Line Through Two Points, Ramp or Roof)

Slope Calculator

Enter the coordinates of two points on the line.

Point 1
Point 2

Slope (m):

-

Angle of inclination (θ):

-

Percent grade:

-

Equation of the line:

-

Sloped length (same unit):

-

Calculation:

-

This calculator finds the slope of a line through two points. You get the slope m, the angle of inclination, the percent grade and the equation of the line in the form y = mx + b. It also has a ramp and roof mode that finds the slope from how far something rises and how far it runs.

Below you will find the formulas, worked examples, conversion tables between percent grade, degrees and ratio, and the most common questions.

How to use the slope calculator

Step 1: Choose Two points for a line on the coordinate plane, or Ramp or roof if you know the rise and the run.

Step 2: Enter the values. You can type a decimal point or a comma, for example 2.5 or 2,5, and negative numbers are fine. In ramp mode, use the same unit for the rise and the run.

Step 3: Click Calculate or press Enter.

Step 4: The slope, the angle and the equation appear in the panel. The Calculation box shows every operation with your numbers.

Slope formula

Slope measures how much a line rises or falls for each unit it moves to the right. For two points (x1, y1) and (x2, y2):

m = (y2 - y1) ÷ (x2 - x1)

The sign tells you the direction. A positive m means the line goes up from left to right, a negative m means it goes down, and m = 0 is a horizontal line. If x2 = x1 the line is vertical and the slope is undefined, because you cannot divide by 0.

The angle of inclination θ is the angle the line makes with the horizontal, and the percent grade is m times 100:

θ = arctan(m)
Percent grade = m × 100

If m is negative, θ comes out negative: the angle is measured downward from the horizontal. Adding 180° gives the angle measured from the positive x-axis.

For the equation of the line, first find b, the point where the line crosses the y-axis:

b = y1 - m × x1, then y = mx + b

For a ramp, roof or staircase, the slope is the rise divided by the horizontal run. The length of the sloped surface is the hypotenuse of the triangle they form:

m = rise ÷ run, length = √(rise² + run²)

Slope examples

Example 1: The line through (1, 3) and (5, 7)

m = (7 - 3) ÷ (5 - 1) = 4 ÷ 4 = 1

θ = arctan(1) = 45°

b = 3 - 1 × 1 = 2

Equation: y = x + 2

The slope is 1, the line makes an angle of 45° with the horizontal, and the grade is 100 %.

Example 2: The line through (2, 8) and (6, 2)

m = (2 - 8) ÷ (6 - 2) = -6 ÷ 4 = -1.5

θ = arctan(-1.5) ≈ -56.31°

Measured from the positive x-axis: 180° + (-56.31°) = 123.69°

b = 8 - (-1.5) × 2 = 11

Equation: y = -1.5x + 11

The slope is negative, so the line goes down from left to right. Its equation is y = -1.5x + 11.

Example 3: Vertical and horizontal lines

The points (4, 1) and (4, 6) have the same x-coordinate, so x2 - x1 = 0. You cannot divide by 0: the slope is undefined and the line is vertical, with equation x = 4.

The points (-2, 3) and (5, 3) have the same y-coordinate, so y2 - y1 = 0 and m = 0 ÷ 7 = 0. The line is horizontal, with equation y = 3.

Example 4: The slope of a wheelchair ramp

A ramp rises 2.5 ft over 30 ft of horizontal run. We use Ramp or roof mode with rise = 2.5 and run = 30:

m = 2.5 ÷ 30 ≈ 0.08333

0.08333 × 100 ≈ 8.333 %

θ = arctan(0.083333) ≈ 4.76°

1 : (30 ÷ 2.5) = 1 : 12

The ramp grade is 8.333 %, its angle is 4.76° and its sloped length is 30.1 ft. A ratio of 1 : 12 is the steepest running slope the ADA Standards allow for a new ramp.

Percent grade to degrees and ratio table

Percent gradeAngleRatio (rise : run)
1 %0.57°1 : 100
2 %1.15°1 : 50
5 %2.86°1 : 20
10 %5.71°1 : 10
12.5 %7.13°1 : 8
15 %8.53°1 : 6.667
20 %11.31°1 : 5
25 %14.04°1 : 4
30 %16.7°1 : 3.333
40 %21.8°1 : 2.5
50 %26.57°1 : 2
75 %36.87°1 : 1.333
100 %45°1 : 1

Common ramp ratios

RatioPercent gradeAngle
1 : 205 %2.86°
1 : 166.25 %3.58°
1 : 128.333 %4.76°
1 : 1010 %5.71°
1 : 812.5 %7.13°
1 : 616.67 %9.46°
1 : 425 %14.04°
1 : 250 %26.57°
1 : 1100 %45°

Degrees to percent grade table

AnglePercent gradeSlope (m)
1°1.746 %0.01746
2°3.492 %0.03492
3°5.241 %0.05241
5°8.749 %0.08749
10°17.63 %0.1763
15°26.79 %0.2679
20°36.4 %0.364
25°46.63 %0.4663
30°57.74 %0.5774
45°100 %1
60°173.21 %1.732
75°373.21 %3.732

Roof pitch table

In the United States a roof pitch is written as the rise in inches for every 12 inches of run, such as 6/12. To use the calculator, enter the first number as the rise and 12 as the run.

Roof pitchSlope (m)Percent gradeAngle
1 / 120.083338.333 %4.76°
2 / 120.166716.67 %9.46°
3 / 120.2525 %14.04°
4 / 120.333333.33 %18.43°
5 / 120.416741.67 %22.62°
6 / 120.550 %26.57°
7 / 120.583358.33 %30.26°
8 / 120.666766.67 %33.69°
9 / 120.7575 %36.87°
10 / 120.833383.33 %39.81°
11 / 120.916791.67 %42.51°
12 / 121100 %45°

Frequently asked questions

How do you find the slope between two points?

Subtract the y-coordinate of the first point from the second, subtract the x-coordinate of the first point from the second, and divide the first difference by the second. For (0, 0) and (3, 4): m = 4 ÷ 3 = 1.333.

What is the slope of a vertical line and of a horizontal line?

A horizontal line has slope 0. A vertical line has an undefined slope, because its run is 0 and you cannot divide by 0. Its equation is x = a number.

How do I convert slope to percent and to degrees?

For percent, multiply m by 100. For degrees, use θ = arctan(m). A slope of 1 is 100 % and equals 45°, not 100°. A percent grade can go above 100 %, but the angle is always below 90°.

How do I find the pitch angle of a roof or a ramp?

Divide the rise by the horizontal run in the same unit. A 6/12 roof pitch gives m = 0.5, which is 50 % and 26.57°. Use Ramp or roof mode and enter 6 and 12.

How do I get the equation of a line from two points?

Find m, then b = y1 - m × x1, and write y = mx + b. For (1, 2) and (3, 6): m = 2, b = 0, and the equation is y = 2x.

Learn more

Related calculators

You can explore other calculators here.