How to find a unit vector orthogonal to a line

geometrylinear algebraorthogonality

I am looking at an academic paper. In one section of it I need to find a line orthogonal to the between two points. The paper says:

Given a point p ∈ δΩ the normal direction is computed as follows: i) the
positions of the “control” points of δΩ are filtered via a
bi-dimensional Gaussian kernel and, ii)np is estimated as the unit
vector orthogonal to the line through the preceding and the successive
points in the list.

I am working on a 2D image. How would I find a unit vector orthogonal to the line...

I have calculated the slop-intercept form of the line between two points, and taking the negative reciprocal gives me the slope perpendicular to that line. However, this is just a scalar number, I do not understand how to get a unit vector from this.

Any ideas?

Best Answer

Since you already have the slope you just need to understand how to turn it into a vector. The usual interpretation of a slope is,

$$ Slope = rise / run,$$

this implicitly describes a vector with y-component equal to the $rise$ and x-component equal to the $run$.

$$ \vec{v} = ( run, rise )$$

The vector isn't normalized yet because its magnitude is not $1$. To normalize a vector you just divide it by its own magnitude. In our case the magnitude of the vector is,

$$\| \vec{v} \| = \sqrt{run^2 + rise^2},$$

and so our normalized vector is,

$$ \hat{v} = \frac{\vec{v}}{\|\vec{v}\|}$$ $$ \hat{v} = \Bigg( \frac{run}{\sqrt{run^2 + rise^2}}, \frac{rise}{\sqrt{run^2 + rise^2}} \Bigg)$$