If you have slope, m, and want to have a direction vector instead, $$ \mathbf{u}=\left(\begin{array}{c} 1\\ m \end{array}\right). $$ For example, if $m=\frac{2}{3},$ then $$ \mathbf{u=}\left(\begin{array}{c} 1\\ 2/3 \end{array}\right)=\left(\begin{array}{c} 3\\ 2 \end{array}\right) $$

If it is pointing the wrong way, then $$ \mathbf{u}=\left(\begin{array}{c} -1\\ -m \end{array}\right) $$

Converting from a direction vector to a slope can only be done if $u_x$ is non-zero. $$ \mathbf{u}=\left(\begin{array}{c}u_x\\u_y \end{array}\right) \qquad m=\frac{u_{y}}{u_{x}}. $$

Just a reminder: If $\mathbf{u}$ is a 2-d vector, then $|\mathbf{u}|=\sqrt{u_{x}^{2}+u_{y}^{2}}.$
The definition and vertical bars indicate a "modulus'', however,
it is loosely referred to as absolute value.

There is a geometric definition of vector dot product
\[
\mathbf{u\cdot v=|u|\cdot|v|\cdot}\cos\theta
\]
In words, The dot product of two vectors is equal to the product of
their lengths and the included angle. I have proof for this relationship
in a figure in the next section.
This formula shows that if the included angle is a $90^{\circ}$ angle
that the $\cos\theta$ will be zero and thus the dot product of two
orthogonal vectors will be zero.
From standard form,
\[
ax+by+c=0,
\]
the slope can be shown to be $-\frac{a}{b}.$ To make this into a
vector, we will get $\left(\begin{array}{c}
b\\
-a
\end{array}\right)$.
\[
\left(\begin{array}{c}
1\\
-\frac{a}{b}
\end{array}\right)\cdot\left(b\right)=\left(\begin{array}{c}
b\\
-a
\end{array}\right)
\]
All of the lines orthogonal to $ax+by+c=0$ will have slope $\frac{b}{a},$
which becomes vector $\left(\begin{array}{c}
a\\
b
\end{array}\right)$. Now the dot product of these two vectors
\[
\left(\begin{array}{c}
b\\
-a
\end{array}\right)\cdot\left(\begin{array}{c}
a\\
b
\end{array}\right)=ab-ab=0
\]
which proves that $-1/m$ is orthogonal to $m,$ since the length
of the two vectors is non-zero, the cosine of the angle in between
must be zero, thus the angle is $90^{\circ}.$

Let's begin with the same relationship that we used previously, \[ \mathbf{u\cdot v=|u|\cdot|v|}\cos\theta \] where $\theta$ is the angle between the two vectors. However, way more important is \[ \cos\theta=\frac{\mathbf{u\cdot v}}{\mathbf{|u|\cdot|v|}}. \] Why would that be? The intersection point, $E,$ coming from $P$ is given by vector projection, i.e. we will project a new point on the line from a known point on the line by moving some distance along the line. \begin{equation} E=A+(\text{distance})\cdot(\text{line unit direction vector)}\label{eq:Vector Intersection} \end{equation} That distance derived from a right triangle is \[ \text{distance}=\text{hypotenuse}\cdot\cos\theta. \] The hypotenuse is the modulus of vector $\mathbf{|v|}$ and the line's $\textbf{unit}$ direction vector is vector $\hat{\mathbf{u}}=\frac{\mathbf{u}}{|\mathbf{u}|}.$

The point is that we don't need $\theta,$ only $\cos\theta,$ which can be had from $\cos\theta=\frac{\mathbf{u\cdot v}}{\mathbf{|u|\cdot|v|}}.$

**Lemma ** The cosine of an angle between two vectors is given by $\frac{\mathbf{u\cdot v}}{\mathbf{|u|\cdot|v|}}.$

The proof is shown in the following figure.

To find the intersection point coordinates, $E$ in the diagram. Start with the coordinates of $A,$ and add the distance from $A$ to $E$ multiplied times the unit direction vector of the line.

What you are about to learn is that we do not have to know the coordinates of $E$ in order to know how far away from $A$ it is.

\[ E=A+\left(distance \overline{AE}\right)\left(\frac{\mathbf{u}}{|\mathbf{u}|}\right) \] \[ E=A+\left(|\mathbf{v}|\cdot\cos\theta\right)\cdot\frac{\mathbf{u}}{\mathbf{|u|}}. \] and by substitution \[ E=A+\left(|\mathbf{v}|\cdot\frac{\mathbf{u\cdot v}}{|\mathbf{u}|\cdot|\mathbf{v}|}\right)\cdot\frac{\mathbf{u}}{\mathbf{|u|}}. \] It will work nicely as is, but we can cancel things that are not vectors. (The modulus of a vector is a scalar!) \[ \begin{aligned}E= & A+\left(\cancel{|\mathbf{v}|}\cdot\frac{\mathbf{u\cdot v}}{|\mathbf{u}|\cdot\cancel{|\mathbf{v}|}}\right)\cdot\frac{\mathbf{u}}{\mathbf{|u|}}\\ = & A+\left(\frac{\mathbf{u\cdot v}}{|\mathbf{u}|^{2}}\right)\cdot\mathbf{u}\\ = & A+\left(\frac{\mathbf{u\cdot v}}{\mathbf{u^{2}}}\right)\cdot\mathbf{u} \end{aligned} \]A line in polar coordinates is still a line and it will have a slope. Since the line is written as a function of $r(\theta),$ we can use the Cartesian transform to get \[ \begin{aligned}x= & r(\theta)\cdot\cos\theta\\ y= & r(\theta)\cdot\sin\theta \end{aligned} \] The first equation defines $\theta$ implicitly. So we can differentiate the second one and get the slope. \[ \frac{dy}{dx}=\frac{dy}{d\theta}\cdot\frac{d\theta}{dx}. \] Furthermore, since $\frac{d\theta}{dx}=1/(dx/d\theta),$we can write $(\text{Use the multiplication rule }d(uv)=du\cdot v+v\cdot du$) \[ \frac{dy}{dx}=\frac{dy/d\theta}{dx/d\theta}=\frac{r^{\prime}(\theta)\sin\theta+r(\theta)\cos\theta}{r'(\theta)\cos\theta-r(\theta)\sin\theta} \]

Example:
Suppose we have a line defined as
\[
r(t)=\frac{4}{\cos(t-\frac{\pi}{3})}.
\]
Here is a sketch of the line, determine its slope and direction vector.

**Answer:**
\[
\frac{dy}{dx}=\frac{r^{\prime}(t)\sin t+r(t)\cos t}{r'(t)\cos t-r(t)\sin t}
\]
\[
r'(t)=4\cdot\frac{\sin\left(t-\frac{1}{3}\;\pi\right)}{\cos^{2}\left(t-\frac{1}{3}\;\pi\right)}
\]
\[
\frac{dy}{dx}=\frac{4\cdot\frac{\sin\left(t-\frac{1}{3}\;\pi\right)}{\cos^{2}\left(t-\frac{1}{3}\;\pi\right)}\sin t+\frac{4}{\cos(t-\frac{\pi}{3})}\cos t}{4\cdot\frac{\sin\left(t-\frac{1}{3}\;\pi\right)}{\cos^{2}\left(t-\frac{1}{3}\;\pi\right)}\cos t-\frac{4}{\cos(t-\frac{\pi}{3})}\sin t}
\]
which will simplify to
\[
\frac{-\cos\left(t\right)\cos\left(\frac{1}{3}\left(3t-\pi\right)\right)-\sin\left(t\right)\sin\left(\frac{1}{3}\left(3t-\pi\right)\right)}{-\cos\left(t\right)\sin\left(\frac{1}{3}\left(3t-\pi\right)\right)+\cos\left(\frac{1}{3}\left(3t-\pi\right)\right)\sin\left(t\right)}.
\]
Let $\alpha=\frac{1}{3}(3t-\pi)$ and rearrange the terms:
\[
\frac{-1(\cos t\cdot\cos\alpha+\sin t\cdot\sin\alpha)}{\sin t\cdot\cos\alpha-\cos t\cdot\sin\alpha}
\]
which is by the sum identity rule,
\[
\frac{-\cos(t-\alpha)}{\sin(t-\alpha)}
\]
but $\alpha$ is $(t-\pi/3),$so substitute:
\[
\frac{-\cos(t-t+\pi/3)}{\sin(t-t+\pi/3)}=\frac{-\cos(\pi/3)}{\sin(\pi/3)}=-\frac{\sqrt{3}}{3}=SLOPE
\]
The direction vector will be
\[
u=\left(\begin{array}{c}
1\\
-\frac{\sqrt{3}}{3}
\end{array}\right)=\left(\begin{array}{c}
3\\
-\sqrt{3}
\end{array}\right)
\]

Now that was a lot of fun, but it would have been quicker to note that the form of the equation gave us point $P(4,\pi/3)$ and that means that the line is 4 units from the origin and its perpendicular angle is $\pi/3.$ Thus the perpendicular line has slope $\tan(\pi/3)=$ and thus the "line'' has slope \[ \frac{-1}{m}=\frac{-1}{\tan\left(\frac{\pi}{3}\right)}=-\frac{1}{\sqrt{3}}=-\frac{\sqrt{3}}{3}=SLOPE \]

Now that was a lot of fun, but it would have been quicker to note that the form of the equation gave us point $P(4,\pi/3)$ and that means that the line is 4 units from the origin and its perpendicular angle is $\pi/3.$ Thus the perpendicular line has slope $\tan(\pi/3)=$ and thus the "line'' has slope \[ \frac{-1}{m}=\frac{-1}{\tan\left(\frac{\pi}{3}\right)}=-\frac{1}{\sqrt{3}}=-\frac{\sqrt{3}}{3}=SLOPE \]