Find the slope of a straight line from two points, or find the second point when you already know one point, a distance, and either the slope or the incline angle. Results include θ, ΔX, ΔY, distance, intercepts, and the line equation.
Formula
Slope is rise over run. Given two points (x₁, y₁) and (x₂, y₂):
m = (y₂ − y₁) / (x₂ − x₁) = ΔY / ΔX = tan(θ)
d = √(ΔX² + ΔY²)
A positive m means the line rises from left to right; a negative m means it falls. m = 0 is horizontal. When ΔX = 0 the slope is undefined (a vertical line).
If one point, a distance d, and the slope are known, the heading is θ = arctan(m) (with negative slopes shifted by 180° so θ is between 0° and 180°). The second point is then
ΔX = d · cos(θ)
ΔY = d · sin(θ)
(x₂, y₂) = (x₁ + ΔX, y₁ + ΔY)
The same line in the opposite direction uses θ + 180°. The slope-intercept equation is y = mx + b with b = y₁ − m x₁.
The default two-point example is (1, 1) and (2, 2): m = 1, θ = 45°, and d = √2 ≈ 1.4142135623731, so y = x. The default point-and-slope example is (1, 1), d = 5, m = 0.75, which is the 3-4-5 triangle: the second point is (5, 4) or (−3, −2) the other way.
Worked identities
| Given | Slope | Distance | θ |
|---|---|---|---|
| (1, 1) and (2, 2) | 1 | √2 ≈ 1.4142135623731 | 45° |
| (3, 4) and (6, 8) | 4/3 | 5 | 53.130102354156° |
| (4, 2) and (6, 10) | 4 | √68 ≈ 8.2462112512353 | 75.963756532074° |
| (1, 2) and (1, 1) | infinity | 1 | 270° |
Examples
Two points (article example)
Points (3, 4) and (6, 8). ΔX = 3, ΔY = 4, so m = 4/3 ≈ 1.3333333333333, d = 5, and θ = arctan(4/3) ≈ 53.130102354156°. The line is y = (4/3)x.
One point, distance, and slope (default)
Point (1, 1), d = 5, m = 0.75 = 3/4. Then θ = arctan(0.75) ≈ 36.87°, ΔX = 4, ΔY = 3, and the second point is (5, 4). Heading the other way lands on (−3, −2). Both share y = 0.75x + 0.25.
Vertical line
Points (1, 2) and (1, 1) have ΔX = 0. The slope is infinity, d = 1, and the heading is 270° (straight down). The equation is x = 1.