title: Position of two closest points on the lines
body: <p>I have found algorithm to calculate shortest distance between two lines in 3D and rewrite it in Python.But also I would like to enchanced it that it could return not only distance,but also the postion of closest points.</p>
  
  <pre><code>def line2line(-0.073455669 4.9843092 0.26107353 0.0 0.0 -1.0 -3.85838175 12.1999998 -4.50372314 0.405142069 -0.76723671 0.497199893):
      epsilon = 0.00000001
      L1P0 = np.array([xbeam,ybeam,zbeam]) #position of P0 on first line
      L2P0= np.array([xout,yout,zout]) #position of P0 on first line
      L1P1 = np.array([xbeam + ubeam ,ybeam + vbeam ,zbeam + wbeam]) #ubeam,vbeam and wbeam are direction cosines
      L2P1 = np.array([xout + cx,yout + cy,zout + cz]) #cx,cy,cz are direction cosines
      u = L1P1 - L1P0
      v = L2P1 - L2P0
      w = L1P0 - L2P0
      a = np.dot(u,u)
      b = np.dot(u,v)
      c = np.dot(v,v)
      d = np.dot(u,w)
      e = np.dot(v,w)
      D = a*c - b*b
      if D &lt; epsilon:
          sc = 0.0
          tc = d/b if b&gt;c else e/c
      else:
          sc = (b*e - c*d) / D
          tc = (a*e - b*d) / D
      dP = w + (sc * u) - (tc * v)
      return np.linalg.norm(dP)
  </code></pre>
  
  <p>It returns around 0.049 which is correct but when I tried to print 
      w + (sc * u) or 
      (tc * v) what I was thinking it was position,it printed me:</p>
  
  <pre><code>0.        ,   0.        , -19.82274615
  3.8142822 , -7.22328672,  4.68097699 
  </code></pre>
  
  <p>It's not correct.Coordinates I'm looking for for one of these points are:</p>
  
  <pre><code>-0.073455669 4.9843092 0.26107353
  </code></pre>
  
  <p>Algorithm I have found <a href="http://geomalgorithms.com/a07-_distance.html#dist3D_Line_to_Line()" rel="nofollow noreferrer">here</a></p>