Calculate parallel distance between vector and point

159 Views Asked by At

Given is a point $A$, an angle $\alpha$ and a point $B$ (see picture). The two parallel lines go through $A$ and $B$ and have the angle $\alpha$. How is the distance between the two parallel lines calculated?

enter image description here

Follow-up-question: Is it possible to return a negative distance if the parallel line of $B$ is above the parallel line of $A$?

3

There are 3 best solutions below

3
On BEST ANSWER

The distance between the parallel lines is just the perpendicular distance from $B$ to the line through $A$. If $A=(x_A,y_A)$, then the point-normal form of equation of the line through $A$ gives us $$(x-x_A)\sin\alpha-(y-y_A)\cos\alpha = 0.$$ The distance to $B=(x_B,y_B)$ is then given by a standard formula: $${\lvert(x_B-x_A)\sin\alpha-(y_B-y_A)\cos\alpha\rvert \over \sqrt{\sin^2\alpha+\cos^2\alpha}} = \lvert(x_B-x_A)\sin\alpha-(y_B-y_A)\cos\alpha\rvert.\tag{*}$$ This is essentially the length of the orthogonal projection of $B-A$ onto the unit normal vector $(\sin\alpha,-\cos\alpha)$ to the line.

If the line is not vertical, we can always arrange for the $y$-component of this normal vector to be negative so that it defines “down” relative to the line through $A$. If you drop the absolute value from (*), the sign of the resulting expression tells you in which half-plane $B$, and so also the line through $B$, lies relative to the line through $A$: if positive, it’s on the half-plane into which the normal points—“below” the line for our choice of normal; if negative, it’s in the other half-plane—“above” the line; if zero, $B$ lies on the line through $A$.

1
On

Let $A = (a_{1},a_{2})$ and $B = (b_{1},b_{2})$. Then given $\alpha$, the distance between the parallel lines given by the two should be

$$\sqrt{(b_{2} - a_{2})^{2} + (b_{1} - a_{1})^{2}} \ \sin\left(\left|\tan^{-1}\left(\frac{a_{2}-b_{2}}{a_{1}-b_{1}}\right)-\alpha\right|\right)$$

0
On

enter image description here

Given $A(x_a, y_a), B(x_b, y_b)$ and $\alpha$: $$|AC| = |AB| \cdot sin\beta$$ $$|AB| = \sqrt{(x_b-x_a)^2+(y_b-y_a)^2}$$ $$\beta=\gamma-\alpha$$ $$\gamma=tan^{-1}\Biggl(\frac{dy}{dx}\Biggr)=tan^{-1}\Biggl(\frac{y_b-y_a}{x_b-x_a}\Biggr)$$