Calculate distance between two parallel lines

geometrylinear algebra

Suppose there are two parallel lines: $w_1x_1+w_2x_2=c_1$ (Line 1) and $w_1x_1+w_2x_2=c_2$ (Line 2). What is the distance between them (the shortest distance between any two points)?

I know the answer is $d=\frac{|c_1-c_2|}{||w||}$ where $||w||=\sqrt{w_1^2+w_2^2}$.

The method I was going to calculate is as follows:

1) find any point on Line 1 $(x_1^0,x_2^0)$ such that $w_1x_1^0+w_2x_2^0=c_1$

2) calculate the perpendicular line (Line 3) to Line 1 and passing through $(x_1^0,x_2^0)$

3) find the point $(x_1^1,x_2^1)$ where Line 3 intersects Line 2

4) calculate the distance between $(x_1^0,x_2^0)$ and $(x_1^1,x_2^1)$

However I couldn't figure out the algebra of this method. Can someone show me the steps of the above calculation? Or is there any simpler way to calculate this? Thanks.

Best Answer

There is an easier way to find the distance using dot product.

Pick the point $A=(x_1,y_1)$ on the fist line and $B=(x_2,y_2)$ on the second line.

The distance between the lines is the length of the projection of $AB$ on the normal vector to the parallel lines

$$d=\frac {|AB.N|}{||N||}=\frac {|c_2-c_1|}{\sqrt {w_1^2+w_2^2}}$$

You may fill in the details of simplifying the dot product and the norm in the above fraction.

Related Question