Line Representations 1

When doing calculations on the computer, the first thing to know is how to represent data. Depending on the kind of calculations one does, some representations may be easier to work with than another. Geometric lines, in particular, has many representations (even for such a simple concept!). I’ll list down the representations that I know and describe them in detail. Note that I’m assuming that we’re working in Euclidean geometry.

Slope-intercept

$y = mx + b$

This is what is often taught in highschool. One important detail to this representation that is often skipped is that this is a scalar function which is why it is often written as $f(x) = mx + b$. This makes analysis simple (straight integration and differentiation works). Moreover, in the case of a line, the function is a bijection which means that you can easily get the inverse.

The form requires only two numbers for storage: the slope $m$ and y-intercept $b$. However, the problem with this form is that this cannot represent vertical lines (i.e. $x = C$ for some constant $C \in \mathbb{R}$). Moreover, it can only represent lines going in one direction: from left to right. While this might not seem so much of a big deal some geometric algorithms need a notion of line direction or “line sides” (i.e. positioned rays). You actually see the issue of “line sides” when you get exercises that requires you to graph $f(x) = mx - b > 0$ or $f(x) = mx - b < 0$. You’ll end up shading the “top” or “left” of the line with the first inequality and the “bottom” or “right” with the second. However, you’ll notice that if you want to represent this, you’ll end up having to store an additional piece of information: the inequality.

Two points

$p_0 = (x_0, y_0) \quad p_1 = (x_1, y_1)$

Another form taught in highschool is using two points to represent a line. While a line contains infinitely many points, only two points are required to fully determine a line. The nice thing about this is that it can actually represent any line in the Euclidean plane, even vertical lines. Just set $x_0 = x_1 = C$ for some constant $C \in \mathbb{R}$ and set $y_0, y_1 \in \mathbb{R} : y_0 \neq y_1$. The non-equality restriction is to prevent collapsing the line into a singularity.

This form requires 4 numbers for storage. While you can choose any two points in a line, it is recommended that you choose two points which are not too far and not too near to each other and both close to 0 to prevent numerical instabilities in computation.

As a bonus, if you take the ordering of points into consideration, you can use it to represent lines with directions by just changing their order. For example, a line going left to right could be represented by $p_0 = (0,0), p_1 = (1,0)$ while a line going from right to left could be represented by $p_0 = (1,0), p_1 = (0,0)$. Moreover, this form can also represent line segments whose endpoints are the two specified points.

The problem with this representation is that this is hard to directly work with; you don’t have an actual equation that describes the relationship of the two points. More often than not, you’ll be converting this to other representations to do calculations.

Parametric (Point + vector)

$x(t) = at + u \quad y(t) = bt + v \qquad \text{or} \qquad \vec{f}(t) = \langle at + u, bt + v\rangle = \vec{v}t + \vec{p}$

This is basically an extension of the slope-intercept form. Instead of directly placing $x$ in the function $f(x) = mx + b$, we turn $x$ into a function, say $x(t)$ where $t \in \mathbb{R}$, and change $f(x)$ to be also dependent on $t$. The second form of the parametric equation is the same thing but written in vector notation.

Like the two-point form, this also requires 4 numbers for storage. $\vec{p} = \langle u,v \rangle$ is the “starting point” of the line and $\vec{v} = \langle a, b \rangle$ is the direction the line is heading. For lines, $\vec{p}$ can be any point in the line and $\vec{v}$ can be of any magnitude. Also, like the two-point form, this form describes the direction of the line, e.g. $\vec{v} = \langle 0, 1 \rangle$ describes a vertical line going up while $\vec{v} = \langle 0, -1\rangle$ describes a vertical line going down.

If we implement some restrictions, particularly on $t$, this form can be used to represent positioned rays and line segments.

• Restricting the range of $t \text{ to } [0, +\infty)$ gives a positioned ray that starts at $\langle u, v \rangle$. This means that $\vec{p} = \langle u, v \rangle$ is restricted to the starting point of the segment.
• Further restricing the range of $t \text{ to } [0, 1]$ gives a line segment that starts at $\langle u, v \rangle$ and ends at $\langle a + u, b + v \rangle$. This means that in addition to the restriction on $\vec{p}$, $\vec{v} = \langle a, b \rangle$ should also be scaled according to the length of the line segment.

There are two more forms that I’m gonna tackle in the next article.