I have to find the shortest distance between the two lines
I know that i need two points, one each line
So if i pick the points
What's the next step?
Okay, I'm going to derail you and if you wish to seek help from somewhere else go ahead. I had to look this up and I don't recognize your method. (If it is a version of your method I am not seeing the geometry.)
The pay-off for this method is at the end of this (lengthy) post.
First we need to convert your line equations to a different format. I am going to define the vector
to be a vector parallel to the line. We have a vector
which is the position vector from the origin to a general point on the line (x, y, z). Finally we have a vector
which is the position vector from the origin to a specific point on the line (x0, y0, z0).
The equation of the line is
As an example of this, let's look at your first line: (x, y, z) = (1 - 6t, 1 - 3t, 1 - 2t) and the point on the line (x0, y0, z0) = (-5, -2, -1). R0 is easy enough:
So we need M.
Eliminate t from the line equations to give
It is also known that a, b, and c are related by
and use P0:
Now put in your values of x and y in terms of z:
If we choose b = 1/2 that gives us a = 1. c can be found by noting that no value of c will let 3 + 3z = z + 1. So we let c = 0. (This apparent contradiction stems from the derivation of the (x - x0)/a = (y - y0)/b = (z - z0)/c equation.)
So we finally know that
(whew!) Take a breather.
I'll leave it to you to find the equation of your other line. Let's call it
Then the distance between the two lines is
(Perhaps one of the other members will have a faster method for you!)