Guide
Slope and the equation of a line from two points, with intercepts, distance and angle
The slope of a line says how steeply it rises or falls: the change in height for each step across. Roads, roofs, ramps and graphs all have one. Given two points, this calculator finds the slope and writes the line’s equation in three forms, then adds the distance, midpoint, angle and intercepts, and draws the line so you can see whether the answer looks right.
How it works
With points (x1, y1) and (x2, y2), the rise is y2 − y1 and the run is x2 − x1. The slope m is rise divided by run. The y-intercept b follows from y1 = m × x1 + b, and the line is y = mx + b. The point-slope form, y − y1 = m(x − x1), keeps the first point visible. Standard form, Ax + By = C, is built from the rise and run and then reduced by their common factor and given a positive first coefficient, so 6x − 2y = 2 is shown as 3x − y = 1.
What else is reported
The distance between the points comes from the Pythagorean theorem and the midpoint is the average of the coordinates. The angle of inclination is the angle the line makes with the positive x axis, from 0 to 180 degrees. The x- and y-intercepts show where the line crosses the axes, and the percent grade is the slope times 100, the form used for roads and ramps. The page also gives the slope of a parallel line, which is the same, and of a perpendicular line, which is the negative reciprocal.
Vertical and horizontal lines
When x1 equals x2 the run is zero, so the slope is not defined. The page states that, gives the equation as x equals that value, reports an angle of 90 degrees and shows no y-intercept. A horizontal line has a slope of 0, an equation y = a constant, and no x-intercept. If you enter the same point twice, the page explains that two identical points do not define a line.
Edge cases
Coordinates can be negative, decimal or large. A downward line has a negative slope and an angle over 90 degrees. When the slope is not a whole number, the results are shown with up to ten digits. The parallel line has the same slope and the perpendicular line is the negative reciprocal, which does not exist when the original slope is zero.
A worked example
For (1, 2) and (3, 8) the rise is 6 and the run is 2, so the slope is 3. The distance is 6.32455532, the midpoint is (2, 5) and the angle is 71.565051°. The line is y = 3x − 1, written as y − 2 = 3(x − 1) in point-slope form and 3x − y = 1 in standard form, with a y-intercept of −1 and an x-intercept of 0.3333333333. The percent grade is 300%. A road that rises 3 m over 50 m has slope 0.06, a grade of 6%, an angle of 3.4336304° and a length along the slope of 50.08991915 m. The points (−2, 4) and (4, −2) give a slope of −1, an angle of 135° and the line y = −x + 2.
Limits
Only two points are used. For a best-fit line through many points, use regression. The plot is a sketch scaled to fit the page, with no gridlines for measurement, and it is not intended for printing a precise graph. Slopes from map contours or real terrain need the true horizontal and vertical distances in the same unit before you enter them.
Related tools
- Linear Regression Calculator fits a line through many points instead of two.
- Triangle Calculator solves the right triangle formed by the rise and run.
- Roof Pitch Calculator expresses a slope as a pitch in twelve units of run.
- Circle Calculator is the next step for work with coordinates, distances and radii.
Checked against the current version of the Slope Calculator on .

