code: def distance2_to_line(pt, l0, l1):
      '''The perpendicular distance squared from a point to a line
      
      pt - point in question
      l0 - one point on the line
      l1 - another point on the line
      '''
      pt = np.atleast_1d(pt)
      l0 = np.atleast_1d(l0)
      l1 = np.atleast_1d(l1)
      reshape = pt.ndim == 1
      if reshape:
          pt.shape = l0.shape = l1.shape = (1, pt.shape[0])
      result = (((l0[:,0] - l1[:,0]) * (l0[:,1] - pt[:,1]) - 
                 (l0[:,0] - pt[:,0]) * (l0[:,1] - l1[:,1]))**2 /
                np.sum((l1-l0)**2, 1))
      if reshape:
          result = result[0]
      return resulf distance2_to_line(pt, l0, l1):
      '''The perpendicular distance squared from a point to a line
      
      pt - point in question
      l0 - one point on the line
      l1 - another point on the line
      '''
      pt = np.atleast_1d(pt)
      l0 = np.atleast_1d(l0)
      l1 = np.atleast_1d(l1)
      reshape = pt.ndim == 1
      if reshape:
          pt.shape = l0.shape = l1.shape = (1, pt.shape[0])
      result = (((l0[:,0] - l1[:,0]) * (l0[:,1] - pt[:,1]) - 
                 (l0[:,0] - pt[:,0]) * (l0[:,1] - l1[:,1]))**2 /
                np.sum((l1-l0)**2, 1))
      if reshape:
          result = result[0]
      return result
docs: The perpendicular distance squared from a point to a line
      
      pt - point in question
      l0 - one point on the line
      l1 - another point on the line