# Line Segments with Linear Algebra

We saw last time that the parametric equation of a line is given by $$\mathtt{l(k) = p + kv}$$, where p is a point on the line (written as a vector), v is a free vector indicating the slope of the line, and k is a scalar value called the parameter. Turning the knob to change k gives you different points on the line. At the right is the line

$\mathtt{l(k) =} \begin{bmatrix}\mathtt{1}\\\mathtt{3}\end{bmatrix} + \begin{bmatrix}\mathtt{\,\,\,\,1}\\\mathtt{-1}\end{bmatrix}\mathtt{k}$

Substituting different numbers for k gives us different points on the line. These resolve into position vectors.

This setup makes it fairly easy to make a line segment, and to partition that line segment into any ratio you want (this will be our ‘current high school connection’ for this post).

When $$\mathtt{k = 0}$$, we get our position vector back: $$\begin{bmatrix}\mathtt{1}\\\mathtt{3}\end{bmatrix}$$. This is the point (1, 3). When $$\mathtt{k = 1}$$, we have … $\begin{bmatrix}\mathtt{1}\\\mathtt{3}\end{bmatrix} + \begin{bmatrix}\mathtt{\,\,\,\,1 \cdot 1}\\\mathtt{-1 \cdot 1}\end{bmatrix} = \begin{bmatrix}\mathtt{1 + 1}\\\mathtt{3 + (-1)}\end{bmatrix}$

… which is the point (2, 2). And so on to generate all the points on the line. To generate a line segment from (1, 3) to, say, the point where the line crosses the x-axis, we first have to figure out where the line crosses the x-axis. We can do this by inspection to see that it crosses at (4, 0), but let’s set it up too. We start by setting the line equal to the point (x, 0) and solving the resulting system of equations: $\begin{bmatrix}\mathtt{1}\\\mathtt{3}\end{bmatrix} + \begin{bmatrix}\mathtt{\,\,\,\,1}\\\mathtt{-1}\end{bmatrix}\mathtt{k} = \begin{bmatrix}\mathtt{x}\\\mathtt{0}\end{bmatrix} \rightarrow \left\{\begin{array}{c}\mathtt{1+k=x}\\\mathtt{3-k=0}\end{array}\right.$

Adding the equations, we get x = 4, so (4, 0) is indeed where the line crosses the x-axis. To generate points on the line segment from (1, 3) to (4, 0), we use position vectors for both endpoints. Then we can use what’s called a convex combination of k—which is just extremely fancy wording for coefficients that add up to 1. We scale the second position vector, (4, 0) by some k and we scale the first position vector (1, 3) by 1 – k. $\mathtt{l(k) =} \begin{bmatrix}\mathtt{1}\\\mathtt{3}\end{bmatrix}\mathtt{(1-k)} + \begin{bmatrix}\mathtt{4}\\\mathtt{0}\end{bmatrix}\mathtt{k}$

Want the line segment divided into fifths? Then just use k values in intervals of fifths, from 0 to 5 fifths. Transpose the k coefficients to get a different “direction” of partitioning of the line segment.