code: def segments_to_parameters(segments):
      
      segments = np.asanyarray(segments, dtype=np.float64)
      if not util.is_shape(segments, (-1, 2, (2, 3))):
          raise ValueError('incorrect segment shape!',
                           segments.shape)
  
      # make the initial origin one of the end points
      endpoint = segments[:, 0]
      vectors = segments[:, 1] - endpoint
      vectors_norm = np.linalg.norm(vectors, axis=1)
      vectors /= vectors_norm.reshape((-1, 1))
  
      # find the point along the line nearest the origin
      offset = util.diagonal_dot(endpoint, vectors)
      # points nearest [0, 0, 0] will be our new origin
      origins = endpoint + (offset.reshape((-1, 1)) * -vectors)
  
      # parametric start and end of line segment
      parameters = np.column_stack((offset, offset + vectors_norm))
  
      return origins, vectors, parameters
docs: For 3D line segments defined by two points, turn
      them in to an origin defined as the closest point along
      the line to the zero origin as well as a direction vector
      and start and end parameter.
  
      Parameters
      ------------
      segments : (n, 2, 3) float
         Line segments defined by start and end points
  
      Returns
      --------------
      origins : (n, 3) float
         Point on line closest to [0, 0, 0]
      vectors : (n, 3) float
         Unit line directions
      parameters : (n, 2) float
         Start and end distance pairs for each line