How to calculate distance between two parallel lines? 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.
 A: It is easier to figure out the distance from the right triangle formed by one of the lines, the vertical axis and the distance-line itself, as shown in the graph.
The intersections of the vertical axis with the two lines are $-c_1/w_2$ and $-c_2/w_2$, respectively. 
And the tangent of the two line is $\tan\theta=-w_1/w_2$.
According to the right triangle in the graph.
the distance $d$ is simply,
$$d=|c_1/w_2-c_2/w_2|\cos\theta=\frac{|(c_1-c_2)/w_2|}{\sqrt{1+w_1^2/w_2^2}}=\frac{|c_1-c_2|}{\sqrt{w_1^2+w_2^2}}$$
where $\cos\theta=1/\sqrt{1+\tan^2\theta}$ is used.

A: 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. 
A: The distance between two parallel lines $a x+b y+c_{1}=0$ and
$$
a x+b y+c_{2}=0 \text { is }=\frac{\left|c_{1}-c_{2}\right|}{\sqrt{a^{2}+b^{2}}}
$$
(Note: The coefficients of $x \& y$ in both equations should be same)
