6
3
6.708204
2.5
5
2
2.222222e-10
—
deg
0
0
0
-1.111111e-10
6
3
6.708204
2.5
5
2
2.222222e-10
—
deg
0
0
0
-1.111111e-10
The Line Equation from Two Points Calculator determines the equation of a straight line passing through two given points $$(x_1, y_1)$$ and $$(x_2, y_2)$$. This is one of the most fundamental operations in coordinate geometry and serves as the basis for countless applications in engineering, physics, data analysis, and computer graphics.
The slope of a line through two points is given by:
$$m = \frac{y_2 - y_1}{x_2 - x_1}$$
Once the slope $$m$$ is known, the slope-intercept form $$y = mx + b$$ is obtained by substituting one of the points to solve for $$b$$:
$$b = y_1 - m \cdot x_1$$
The slope represents the rate of change of $$y$$ with respect to $$x$$. A positive slope means the line rises from left to right, while a negative slope means it falls. A slope of zero indicates a horizontal line, and an undefined slope (when $$x_1 = x_2$$) indicates a vertical line.
Alternatively, the line can be expressed using the point-slope form:
$$y - y_1 = m(x - x_1)$$
or the two-point form:
$$\frac{y - y_1}{y_2 - y_1} = \frac{x - x_1}{x_2 - x_1}$$
This calculator also computes several auxiliary quantities. The distance between the two points is given by the Euclidean distance formula:
$$d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$$
The midpoint of the segment connecting the two points is:
$$M = \left(\frac{x_1 + x_2}{2},\; \frac{y_1 + y_2}{2}\right)$$
The angle that the line makes with the positive x-axis is computed via the arctangent function:
$$\theta = \arctan\left(\frac{y_2 - y_1}{x_2 - x_1}\right)$$
Finding the equation of a line through two points is essential in linear regression, where a best-fit line approximates data trends. In computer graphics, line rasterization algorithms require the slope to determine which pixels to illuminate. In physics, the slope of a position-time graph gives velocity, and the slope of a velocity-time graph gives acceleration. Surveyors use line equations to describe property boundaries and road grades. Financial analysts plot trend lines through price data to forecast market movements.
The rise $$\Delta y = y_2 - y_1$$ and run $$\Delta x = x_2 - x_1$$ decompose the slope into its vertical and horizontal components, which is particularly intuitive for understanding gradients in civil engineering (e.g., road grade expressed as rise over run). Understanding these components helps in converting between slope representations such as percentage grade, angle of inclination, and ratio notation.
Enter the coordinates of two distinct points. The calculator computes the slope $$m = \Delta y / \Delta x$$, the y-intercept $$b = y_1 - m \cdot x_1$$, the distance between the points, the midpoint, and the angle of inclination. If the two x-coordinates are equal, the line is vertical and the slope is undefined.
The slope tells you how steeply the line rises or falls. The y-intercept is where the line crosses the y-axis. Together they give the equation $$y = mx + b$$. The distance and midpoint describe the segment between your two points, and the angle shows the line's orientation relative to the horizontal.
Inputs
Results
The line y = 2x passes through the origin with a slope of 2. The distance between (1,2) and (4,8) is √45 ≈ 6.71.
Inputs
Results
The line y = -2x + 1 falls from left to right. The midpoint lies on the x-axis at (0.5, 0).
When $$x_1 = x_2$$, the denominator $$\Delta x = 0$$ and the slope is undefined. The line is vertical, described by the equation $$x = x_1$$. The calculator will report an infinite slope in this case.
This calculator handles exactly two points to define a unique line. For three or more points that may not be collinear, you would use linear regression (least-squares fitting) to find the best-fit line.
From $$y = mx + b$$, rearrange to $$mx - y + b = 0$$ or equivalently $$Ax + By + C = 0$$ where $$A = m$$, $$B = -1$$, $$C = b$$. Multiply through by any constant to clear fractions if desired.
A slope of zero means the line is perfectly horizontal: $$y = b$$ for all $$x$$. The two points have the same y-coordinate.
The angle is measured counterclockwise from the positive x-axis to the line, ranging from $$-90°$$ to $$90°$$. A positive angle indicates the line rises to the right; a negative angle indicates it falls.
Yes, the Euclidean distance formula $$d = \sqrt{\Delta x^2 + \Delta y^2}$$ is a direct application of the Pythagorean theorem, treating $$\Delta x$$ and $$\Delta y$$ as the legs of a right triangle.
Roboculator Team
The Roboculator Team explains calculations, planning tools, and practical formulas in clear language for real-life situations.
How helpful was this calculator?
Be the first to rate!
Distance Calculator (2D)
Coordinate Geometry Calculators
Distance Calculator (3D)
Coordinate Geometry Calculators
Midpoint Calculator
Coordinate Geometry Calculators
Endpoint Calculator
Coordinate Geometry Calculators
Slope Calculator
Coordinate Geometry Calculators
Slope Intercept Form Calculator
Coordinate Geometry Calculators