Daniel Sapoundjiev on
  Line equations

Line equations in 2D

Line is a straight path and is infinite. There are no turns.

2 points describes the line

2 points are enough to describe the line.
And they are enough to write down equations.
Equations to calculate points of the line, or intersections point with other line etc.

Line equations calculation

Lets have our 2 points on the line.
They have coordinates x1, y1 and x2, y2 And lets have x, y representing any point on the line
Than we have this equation
(x2 - x1) / (y2 - y1) = (x - x1) / (y - y1)
Cause they are common triangles. if we connect the points and then draw the horizontal and vertical lines from them.

So, lets start from (x2 - x1) / (y2 - y1) = (x - x1) / (y - y1)
y - y1 = (x1 - x2) (y2 - y1) / (x2 - x1) // Two-point form equation

Again from the beginning for the other equations
(x2 - x1) / (y2 - y1) = (x - x1) / (y - y1)
(x - x1)(y2 - y1) = (x2 - x1)(y - y1)
xy2 - xy1 - x1y2 + x1y1 = x2y - x2y1 - x1y + x1y1
x(y2 - y1) + y(x1-x2) + x2y1 - x1y2 = 0

A = y2 - y1
B = x1 - x2
C = x2y1 - x1y2

Ax + By + C = 0 // General (or standard) form of the equation

By = -Ax - C
y = -A/Bx - C/B

m = -A/B = (y1 - y2)/(x1 - x2)
b = -C/B = (x1y2 - x2y1)/(x1 - x2)

y = mx + b // Slope–intercept form

Back to main menu