# Calculate shortest distance between two lines

We are considering the two line in space as line1 and line2. The line1 is passing though point A (a

_{1},b_{1},c_{1}) and parallel to vector V_{1}and The line2 is passing though point B(a_{2},b_{2},c_{2}) and parallel to vector V_{2}. 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 a_{12 } = (a_{1} - a_{2}), b_{12} = (b_{1} - b_{2}) and c_{12} = (c_{1} - c_{2}).

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.