Equation of a straight line
General Equation of a Straight Line

In 2D or 3D, the vector equation of a straight line depends on two details: a position vector of a point on the line and a direction vector dictating the direction of the line.

The general form of the line is given as r = a + tb where r is the position vector to any point (x, y, z) on the line, a is the position vector to a known point on the line, t is a scalar parameter and b is the direction vector of the line.
Coordinate Geometry of a Line

In 2D, the equation of a line can be written in the form y = mx + c, where m is the slope of the line and c is the yintercept.

A line can also be described using the slopepoint form as y  y₁ = m(x  x₁), where (x₁, y₁) is any point on the line and m is the slope.

The slope of the line measures the change in ycoordinates against the change in xcoordinates, and can be found using the formula m = (y₂  y₁) / (x₂  x₁).

The normal vector to a line denoted as n = [a, b], can be used to generate the equation of the line in the format ax + by + c = 0, where c is a constant.
Lines in 3D Space

In 3D, the equation of a straight line can be written as a pair of parametric equations or vector equations.

The parametric equations of a line are x = a + mt, y = b + nt, z = c + pt where (a, b, c) is a point on the line and (m, n, p) are the direction ratios of the line.

For lines in 3D, the concept of the direction vector becomes especially important. This vector d = [m, n, p] parallels the line and its magnitude and direction is proportional to the slope of the line.
Intersection of Two Lines

Two lines can intersect, be parallel, or be skew.

To determine if two lines intersect, you can equate the parametric equations of the two lines and attempt to solve for the parameters.

If a single solution exists for the parameters, the lines intersect at the point corresponding to that parameter value. If no solutions exist, the lines are skew. If infinite solutions exist, the lines are parallel.