code: def plane_lines(plane_origin,
                  plane_normal,
                  endpoints,
                  line_segments=True):
      
      endpoints = np.asanyarray(endpoints)
      plane_origin = np.asanyarray(plane_origin).reshape(3)
      line_dir = util.unitize(endpoints[1] - endpoints[0])
      plane_normal = util.unitize(np.asanyarray(plane_normal).reshape(3))
  
      t = np.dot(plane_normal, (plane_origin - endpoints[0]).T)
      b = np.dot(plane_normal, line_dir.T)
  
      # If the plane normal and line direction are perpendicular, it means
      # the vector is 'on plane', and there isn't a valid intersection.
      # We discard on-plane vectors by checking that the dot product is nonzero
      valid = np.abs(b) > tol.zero
      if line_segments:
          test = np.dot(plane_normal,
                        np.transpose(plane_origin - endpoints[1]))
          different_sides = np.sign(t) != np.sign(test)
          nonzero = np.logical_or(np.abs(t) > tol.zero,
                                  np.abs(test) > tol.zero)
          valid = np.logical_and(valid, different_sides)
          valid = np.logical_and(valid, nonzero)
  
      d = np.divide(t[valid], b[valid])
      intersection = endpoints[0][valid]
      intersection = intersection + np.reshape(d, (-1, 1)) * line_dir[valid]
  
      return intersection, valid
docs: Calculate plane-line intersections
  
      Parameters
      ---------
      plane_origin : (3,) float
          Point on plane
      plane_normal : (3,) float
          Plane normal vector
      endpoints : (2, n, 3) float
          Points defining lines to be tested
      line_segments : bool
          If True, only returns intersections as valid if
          vertices from endpoints are on different sides
          of the plane.
  
      Returns
      ---------
      intersections : (m, 3) float
          Cartesian intersection points
      valid : (n, 3) bool
          Indicate whether a valid intersection exists
          for each input line segment