Let l1 and l2 be lines in space that do not intersect. There are two cases. If l1 and l2 are parallel, the distance between the two lines is the length of any line segment N1 N2, with N1 on l1 and N2 on l2 perpendicular to both lines. If l1 and l2 are not parallel, there are unique points N1 on l1 and N2 on l2 such that the length of the line segment N1N2 is the shortest possible. The length |N1N2| is the distance between the two lines. In fact, the line N1N2 is the common perpendicular of l1 and l2.
If the two lines are skew and have equations r × a1= b1 and r × a2 = b2 where × denotes the vector product, then the distance between the lines equals