## Straight Lines on Rectangular Planes

#### 3.1  Projection

A useful feature of the scalar product is to calculate the length of a projection of a vector on the line of another vector.

For two vectors u = (5.6, 4.2) and v = (1, 7), with common origin denoted O, the perpendicular projection of v on the line containing u is a point denoted P.  The point P is called the perpendicular foot of v on the line of u. The distance from O to P (denoted OP) is proportional to the scalar product of u and v. The distance OP is the scalar product u · v multiplied by the length of u. To obtain the distance OP, divide the scalar product u · v by the length of u.

The length of u is 7:

\begin{align} \mathbf{u} & = (5.6, 4.2) \\ \vert \mathbf{u} \vert & = \vert (5.6, 4.2) \vert \\ & = \sqrt{5.6^{2} + 4.2^{2}} \\ & = \sqrt{31.36 + 17.64} \\ & = \sqrt{49} \\ & = 7 \end{align}

The scalar product u · v equals 35:

\begin{align} \mathbf{u} \cdot \mathbf{v} & = (5.6, 4.2) \cdot (1, 7) \\ & = (5.6)(1) + (4.2)(7) \\ & = 5.6 + 29.4 \\ & = 35 \end{align}

Dividing u · v = 35 with |u| = 7 yields the distance OP = 5. That is the hypotenuse of a 3/4/5 triangle. Note that division by |u| would not have been necessary if u was a unit vector (because a unit vector length is 1).

Consider u = (2.8, 2.1). Then the length of u is 3.5:

\begin{align} \mathbf{u} & = (2.8, 2.1) \\ \vert \mathbf{u} \vert & = \vert (2.8, 2.1) \vert \\ & = \sqrt{2.8^{2} + 2.1^{2}} \\ & = \sqrt{7.84 + 4.41} \\ & = \sqrt{12.25} \\ & = 3.5 \end{align} The scalar product u · v equals 17.5:

\begin{align} \mathbf{u} \cdot \mathbf{v} & = (2.8, 2.1) \cdot (1, 7) \\ & = (2.8)(1) + (2.1)(7) \\ & = 2.8 + 14.7 \\ & = 17.5 \end{align}

Dividing u · v = 17.5 with |u| = 3.5 yields the distance OP = 5 again.

In the preceding examples, the angle subtending (between) u and v was acute (less than 90°). Now consider v = (−7, 1) which subtends an obtuse angle with u (greater than 90°): The scalar product u · v equals −17.5:

\begin{align} \mathbf{u} \cdot \mathbf{v} & = (2.8, 2.1) \cdot (-7, 1) \\ & = (2.8)(-7) + (2.1)(1) \\ & = -19.6 + 2.1 \\ & = -17.5 \end{align}

Dividing u · v = −17.5 with |u| = 3.5 yields the distance OP = −5. The distance is negative because it is in the opposite direction than u on the line containing u.

#### 3.2  Perpendicular Foot Point

The perpendicular projection of v on the line of u is the point denoted P.  The point P is called the perpendicular foot of v on the line of u. The coordinates of P can be found by scaling the unit vector of u with the distance OP.

$\text{unit vector of } \mathbf{u} = \mathbf{\hat{u}} = \frac{\mathbf{u}}{\vert \mathbf{u} \vert} = \left( \frac{u_{x}}{\vert \mathbf{u} \vert}, \frac{u_{y}}{\vert \mathbf{u} \vert} \right)$

$\mathbf{\hat{u}} = \left( \frac{2.8}{3.5}, \frac{2.1}{3.5} \right) = (0.8, 0.6)$

\begin{align} OP \mathbf{\hat{u}} & = -5(0.8, 0.6) \\ & = (-4, -3) \end{align}

#### 3.3  Vector Subtraction (Distance to Line)

Vector subtraction is simply vector addition with one of the vectors scaled with −1. The result is a vector that extends from the head of one of the vectors to the head of the other vector. In this case, it gives us a vector joining the head of v with the point P (head of OP). The length of that vector is the shortest distance from the head of v to the line containing P.

Denoting that vector as d:

\begin{align} \mathbf{d} & = \mathbf{v} - OP \mathbf{\hat{u}} \\ & = \mathbf{v} + (-OP \mathbf{\hat{u}}) \\ & = (-7, 1) + (4, 3) \\ & = (-3, 4) \end{align}

The length of d is the shortest distance from the head of v to the line of u.

\begin{align} \vert \mathbf{d} \vert & = \sqrt{-3^{2} + 4^{2}} \\ & = \sqrt{9 + 16} \\ & = \sqrt{25} \\ & = 5 \end{align}

Sometimes we only need the square of the distance, to compare to other squared distances — in that case, the square root may be skipped.