Without already knowing if the lines intersect, we have to follow through these steps one by one.

Parallel - distance

First check whether the lines are parallel. The lines are parallel if the cross product of the direction vectors is zero. To find distance between parallel lines: Find one point on each line. Let’s call them and . Calculate the vector

The distance between the lines is where is the direction vector for any one of the two lines.

Intersection?

If the lines aren’t parallel, we need to determine whether the lines intersect or are skew. Treat the two parametric equations as a system of equations, and solve for both parameters. If the solutions are valid (check with all equations), then we have an intersection, otherwise the lines are skew. Detailed steps below:

  • Set the first pair of parametric equations (both ) equal to each other. Solve for one of the parameter (parametric variable).
  • Set the second pair of equations equal to each other. Plug the solved parameter in, and solve for the other parameter.
  • Set the third pair equal to each other. Plug the first parameter into it and solve for the other one. Check if the solution for the parametric variable is consistent with step 2. If not, then the lines are skew. If it is, then plug the one parameter into a line equation to obtain the intersection coordinate.

Skew!

To calculate distance between skew lines:

  • Find the cross product between the two direction vectors. If the two lines were moved to the same plane, would be its normal vector.
  • Then find any point on each line ( and ) and calculate the vector . Note that the -component of is the basically distance between these two lines. We can calculate that using projection.
  • The distance between the two lines is the projection of onto :