Noticed that the coefficient of x and y of both line are respectively the same, this is because the slope of both line, m1 and m2 are the same, with
m1=m2=−BA
However, for easier understanding, I'll let it be A1,B1 for l1 and A2,B2 for l2, but bear in mind that they are actually the same.
Since the distance between parallel lines are the same in any given point, we simply set a point P(x0,y0) on l1 and take its distance from l2. Here, we use the formula of distance between a point and a line.
d=A2+B2A2x0+B2y0+C2
Since A1=A2 and B1=B2, the formula can be expressed as
d=A2+B2A1x0+B1y0+C2
Then, we also have
l1:A1x0+B1y0+C1=0
l1:A1x0+B1y0=−C1
Substitute to the formula we have
d=A2+B2−C1+C2
Finally, we can remove everything unnecessary and arrange the formula, we get
Suppose that we have 2 parallel planes:
P1:Ax+By+Cz+D1=0P2:Ax+By+Cz+D2=0
We wish to find the distance between these 2 planes. Note that we want to find the shortest possible distance between the two planes, i.e. the distance if one traveled from P1 to P2 along a segment parallel to the normal vector.
A normal vector to both of these planes is n=⟨A,B,C⟩. Note that ∣n∣=A2+B2+C2.
Suppose you move along the normal vector such that your displacement is kn=⟨kA,kB,kC⟩, for some scalar k. For all points P=(x,y,z)∈R3, define f(P)=Ax+By+Cz. Then:
f(P+kn)=A(x+kA)+B(y+kB)+C(z+kC)f(P+kn)=(Ax+By+Cz)+k(A2+B2+C2)f(P+kn)−f(P)=k∣n∣2
Therefore, a movement of k∣n∣ in the normal direction produces a change of k∣n∣2 in f(P). Suppose that we have 2 points M1∈P1 and M2∈P2 such that M1M2⊥P1,P2. Then:
f(M2)−f(M1)=(−D2)−(−D1)=D1−D2D1−D2=k∣n∣2k∣n∣=A2+B2+C2D1−D2
Note that k∣n∣ is just the displacement in the normal direction! Thus, since geometric distances are always nonnegative, we can say:
M1M2=A2+B2+C2∣D1−D2∣
This means that the distance d between 2 parallel planes of the above form is:
d=A2+B2+C2∣D1−D2∣
This argument can easily be generalized to any number of dimensions. Suppose we have 2 parallel (n−1)-dimensional hyperplanes in n-dimensional hyperspace of the form:
P1:A1x1+A2x2+...+Anxn+B1=0P2:A1x1+A2x2+...+Anxn+B2=0
Then, the distance d between them is:
d=A12+A22+...+An2∣B1−B2∣