Finding the outward normal to a straight line in 2D

590 Views Asked by At

Suppose you have a straight line from $\underline{a}=(2,0)$ to $\underline{b}=(1,4)$.

If we consider the vector format of this straight line, then it will be: $\underline{b}-\underline{a}$. That is the vector: $(1,4)-(2,0)=(-1,4)$.

And I know that, the two vectors: $(4,1)$ and $(-4,-1)$ will be the normal vectors to this straight line $\underline{b}-\underline{a}$.

My question is, whether there is a way to identify the outward normal. That is if we travel from $\underline{a}$ to $\underline{b}$, then the one on your right hand side.

Appreciate your help

(I'm using Python programming. So I included that as well in the name tags)

2

There are 2 best solutions below

0
On

You want the outward normal to point away from the origin. Choose any point on the line. You can choose $\underline{a}$. Then the origin is in the direction $\underline 0-\underline a$. Then look at the angle between the normal and this vector. In fact, you can simplify and just look at the sign of the dot product. Say your normal is $(n_x,n_y)$. Then $$(n_x,n_y)\cdot(-b_x,-by)=-n_xb_x-n_yb_y$$ If the dot product is negative, your normal points away from the origin. If it's positive, the normal is towards origin. If it's $0$, then the original line goes through the origin, so there are no outward or inward directions.

0
On

Just rotate the vector $\vec b-\vec a$ clockwise by 90° or $\vec a-\vec b$ counterclockwise by 90° using the rotation matrix.