What this calculator does
Give it two points in the plane, P(x1, y1) and Q(x2, y2), and it returns the equation of the straight line through them in slope-intercept form, \(y = a\cdot x + b\). It also reports the distance between the two points and the slope angle (inclination) of the line, which you can display in degrees or radians.
How to use it
Enter the coordinates of both points. Choose whether you want the slope angle in degrees (default) or radians. The calculator instantly computes the slope \(a\), the y-intercept \(b\), the distance PQ, and the angle theta. Coordinates are plain dimensionless numbers, so any consistent unit works for the distance output.
The formula explained
Let \(dx = x_2 - x_1\) and \(dy = y_2 - y_1\). The slope is \(a = dy / dx\) (rise over run). The y-intercept is $$b = \frac{x_2\cdot y_1 - x_1\cdot y_2}{x_2 - x_1},$$ which is equivalent to \(b = y_1 - a\cdot x_1\). The distance follows from the Pythagorean theorem: $$d = \sqrt{dx^2 + dy^2}.$$ The slope angle is \(\theta = \arctan(dy / dx)\), measured from the positive x-axis: a positive angle means the line rises to the right, negative means it falls to the right.
Worked example
For P(-4, -1) and Q(2, 2): \(dx = 6\), \(dy = 3\). Slope \(a = 3/6 = 0.5\). Intercept $$b = \frac{2\cdot(-1) - (-4)\cdot 2}{6} = \frac{-2 + 8}{6} = 1,$$ so the line is \(y = 0.5\cdot x + 1\). Distance $$= \sqrt{36 + 9} = \sqrt{45} \approx 6.7082.$$ Angle \(= \arctan(0.5) \approx 0.4636\ \text{rad} \approx 26.565^\circ\).
FAQ
What happens for a vertical line? When \(x_2 = x_1\), the line is parallel to the y-axis. Its slope-intercept form is indeterminate, so slope and intercept return infinity; the distance still equals \(|y_2 - y_1|\) and the angle is \(\pm 90^\circ\).
What about a horizontal line? If \(y_2 = y_1\), the slope is 0 and the angle is 0, giving the equation \(y = b\).
What if both points are the same? The distance is 0 and the line is undefined, since infinitely many lines pass through a single point.