Slope Calculator
Type two points. You get the slope as a fraction and a decimal, the angle, percent grade, distance, midpoint and the equation of the line.
https://flxcode.com/slope-calculator/
Done.
- Slope m
- 0.75
- Rise and run
- 3 up, 4 across
- Angle
- 36.8699° from the x-axis
- Percent grade
- 75%
- Line
- y = 0.75x − 0.25
- Perpendicular slope
- -4/3 (-1.3333)
- Distance
- 5
- Midpoint
- (5, 3.5)
The steps, with your numbers
- m = (y₂ − y₁) / (x₂ − x₁) = (5 − 2) / (7 − 3) = 3 / 4 = 0.75
- angle = arctan(m) = arctan(0.75) = 36.8699°
- b = y₁ − m × x₁ = 2 − 3/4 × 3 = -1/4
- distance = √((x₂ − x₁)² + (y₂ − y₁)²) = √(4² + 3²) = √25 = 5
- midpoint = ((x₁ + x₂) / 2, (y₁ + y₂) / 2) = ((3 + 7) / 2, (2 + 5) / 2) = (5, 3.5)
No ads. No account. Nothing you type or record is uploaded. We count page events with a daily code. Check it.
Problem or idea? Email us
The formula
m = (y₂ − y₁) / (x₂ − x₁)
Rise over run. The rest follows from m:
- Angle from the horizontal:
θ = arctan(m) - Percent grade:
m × 100 - Line equation:
y = mx + b, withb = y₁ − m × x₁ - Distance:
√((x₂ − x₁)² + (y₂ − y₁)²) - Midpoint:
((x₁ + x₂) / 2, (y₁ + y₂) / 2)
Worked examples
| Line | Points | Slope | Angle | Equation | Distance |
|---|---|---|---|---|---|
| Rising | (3, 2) to (7, 5) | 0.75 | 36.8699° | y = 0.75x − 0.25 | 5 |
| Falling | (-2, 4) to (2, -4) | -2 | -63.4349° | y = −2x | 4√5 ≈ 8.9443 |
| Fraction | (0, 0) to (3, 1) | 1/3 (0.3333) | 18.4349° | y = (1/3)x | √10 ≈ 3.1623 |
| Flat | (1, 3) to (9, 3) | 0 | 0° | y = 3 | 8 |
| Vertical | (2, 1) to (2, 6) | undefined (vertical line) | 90° | x = 2 | 5 |
| Decimals | (0.5, 1.25) to (2.5, 3.25) | 1 | 45° | y = x + 0.75 | 2√2 ≈ 2.8284 |
The distance in the first row is 5 because the rise 3 and run 4 make a 3-4-5 right triangle. See the Pythagorean theorem calculator for that step.
Slope, grade and angle side by side
| Rise to run | Percent grade | Angle |
|---|---|---|
| 1:20 | 5% | 2.86° |
| 1:12 | 8.33% | 4.76° |
| 1:10 | 10% | 5.71° |
| 1:4 | 25% | 14.04° |
| 1:2 | 50% | 26.57° |
| 1:1 | 100% | 45° |
Percent grade and angle are not the same. Grade keeps climbing past 100% while the angle stops at 90°. For roofs, which use rise per 12 inches of run, use the roof pitch calculator. For stairs, see the stair calculator.
Numbers this uses
- The steepest wheelchair ramp the US ADA Standards allow is 1:12, which is 8.33%, or 4.76° (ADA Standards 405.2).
- The slope is computed on exact fractions. 1/3 stays 1/3, with 0.3333 beside it, so no rounding noise from decimals like 0.1.
- Angles and the arctan step use the double-precision value of π that your browser has built in.
- "Decimals" only rounds what is shown.
- Values above 1,000,000,000,000 are rejected so the arithmetic stays accurate.
Limits
- Two points on a flat plane. The units of x and y should match if you want the angle to mean something, such as feet and feet.
- The angle is the line's angle from the x-axis, between −90° and 90°. A falling line gives a negative angle.
- Identical points give an error, because many lines pass through one point.
Nothing you type is uploaded. We count events without cookies (details).
FAQ
How do I calculate the slope between two points?
Divide the rise by the run: m = (y₂ − y₁) / (x₂ − x₁). For (3, 2) and (7, 5), that is (5 − 2) / (7 − 3) = 3/4 = 0.75. The tool shows the fraction and the decimal, and the steps with your numbers.
What is the slope of a vertical line?
Undefined. Both points have the same x, so the run is 0 and you can not divide by zero. The line is written x = 3 (or whatever x is). The tool says "undefined (vertical line)" and gives the distance, midpoint and the perpendicular slope, which is 0.
What is the slope of a horizontal line?
Zero. Both points have the same y, so the rise is 0. The line is y = c, and its perpendicular line is vertical, with an undefined slope.
Does the order of the points matter?
No. Swapping the points flips both the rise and the run, so the signs cancel and the slope stays the same. Only keep each x with its own y.
How do I turn the slope into an angle or a percent grade?
The angle is arctan(m), measured from the horizontal. A slope of 0.75 is 36.87°. The percent grade is the slope times 100, so 0.75 is a 75% grade. A 45° line has slope 1 and a grade of 100%, not 45%.
How do I get the equation of the line?
Find m, then b = y₁ − m × x₁, and write y = mx + b. For (3, 2) and (7, 5), m = 0.75 and b = 2 − 0.75 × 3 = −0.25, so y = 0.75x − 0.25. The tool gives this for any two points except a vertical line.
How do I know if two lines are parallel or perpendicular?
Parallel lines have the same slope. Perpendicular lines have slopes that multiply to −1, so the perpendicular slope is −1/m. The tool shows it. A horizontal line is perpendicular to a vertical one.
Are my numbers uploaded or saved?
No. The maths runs in your browser. What you type is not put in the address bar, not stored and not counted. We only count the kind of line: sloped, horizontal or vertical.
More from FLXCode
Pythagorean Theorem CalculatorNew
Find the missing side of a right triangle, or test if three sides make one. Exact roots and the steps.
Roof Pitch CalculatorNew
Roof pitch as x/12, angle and percent grade from rise and run, with rafter length and roof area factors.
Stair CalculatorNew
Number of risers, riser height, tread depth, total run and stringer length, with a check against IRC limits.
Area CalculatorNew
Area of a rectangle, triangle, circle, trapezoid, parallelogram, ellipse, sector or polygon, with the formula.