# Calculate shortest distance between two lines

#### Enter the values for :

Line passing through the point A(a1,b1,c1) parallel to the vector V1(p1,q1,r1)

 point A : vector V1 :

#### Enter the values for :

Line passing through the point B(a2,b2,c2) parallel to the vector V2(p2,q2,r2)

 point B : vector V2 :

 Shortest distance between two lines (d)

We are considering the two line in space as line1 and line2. The line1 is passing though point A (a1,b1,c1) and parallel to vector V1 and The line2 is passing though point B(a2,b2,c2) and parallel to vector V2. We can find out the shortest distance between given two lines using following formulas: $$d=| \frac {( \overrightarrow{V_{\,1}} \times \overrightarrow{V_{\,2}}) \cdot \overrightarrow{P_{\,1} P_{\,2}}}{| \overrightarrow{V_{\,1}} \times \overrightarrow{ V_{\,2}} | } | , at | \overrightarrow{V_{\,1}} \times \overrightarrow{ V_{\,2}} | \neq {0}$$ $$=| \frac {( q_{\,1}r_{\,2} - q_{\,2}r_{\,1})a_{\,12} + (r_{\,1}p_{\,2} - r_{\,2}p_{\,1})b_{\,12} + (p_{\,1}q_{\,2} - p_{\,2}q_{\,1})c_{\,12} } { \sqrt{(q_{\,1}r_{\,2} - q_{\,2}r_{\,1})^{2}+(r_{\,1}p_{\,2} - r_{\,2}p_{\,1})^{2} + (p_{\,1}q_{\,2} - p_{\,2}q_{\,1})^{2} }} |$$ $$d=| \frac { \overrightarrow{V_{\,1}} \cdot \overrightarrow{P_{\,1} P_{\,2}}}{| \overrightarrow{V_{\,1}} | } | , at | \overrightarrow{V_{\,1}} \times \overrightarrow{ V_{\,2}} | = {0}$$ $$=|\frac{ \sqrt{ (b_{\,12}r_{\,1} - c_{\,12}q_{\,1})^{2} + (c_{\,12}p_{\,1} - a_{\,12}r_{\,1})^{2} + (a_{\,12}q_{\,1} - b_{\,12}p_{\,1})^{2} } } { \sqrt{ p_{\,1}^{2} + q_{\,1}^{2} + r_{\,1}^{2} } }|$$

where a12 = (a1 - a2), b12 = (b1 - b2) and c12 = (c1 - c2).

The distance between two straight lines on a plan is the minimum distance between any two points lying on the lines.
The distance between two parallel lines is the perpendicular distance from any point on one line to the other line.
The distance between two intersecting lines is eventually comes to zero and
The distance between two skew lines is equal to the length of the perpendicular between the lines.