Given a pair of points A
and B
in a vector space of arbitrary dimension, one can describe the line between them as
X = A + t*(B - A) = (1 - t)*A + t*B
so in 2d this would be
x = Ax + t*(Bx - Ax) = (1 - t)*Ax + t*Bx
y = Ay + t*(By - Ay) = (1 - t)*Ay + t*By
As t
assumes any real value, this will produce all points along the line. The representation is not unique, as any pair of distinct points along the line will describe the same line. It is easy to switch between full line and line segment using this representation, since restricting t
to the range [0, 1]
will yield a line segment instead.