original_docstring:  Calculate the points of a line in a given rectangle
  
              :param rect: Parameters of a rectangle (min x, min y, max x, max y).
              :type  rect: list of float
              :param line: line given as y=a*x+b or a*x+b*y+c=0
              :type  line: list of float
              :rtype: list of pairs of float
          
docstring: Calculate the points of a line in a given rectangle
docstring_tokens: Calculate the points of a line in a given rectangle
code: def __intersect(self, rect, line):
          """ Calculate the points of a line in a given rectangle
  
              :param rect: Parameters of a rectangle (min x, min y, max x, max y).
              :type  rect: list of float
              :param line: line given as y=a*x+b or a*x+b*y+c=0
              :type  line: list of float
              :rtype: list of pairs of float
          """
          l = []
          xmin, xmax, ymin, ymax = rect
          a, b, c = line
  
          assert a != 0 or b != 0
  
          if a == 0:
              y = -c/b
              if y <= ymax and y >= ymin:
                  l.append((xmin, y))
                  l.append((xmax, y))
              return l
          if b == 0:
              x = -c/a
              if x <= xmax and x >= xmin:
                  l.append((x, ymin))
                  l.append((x, ymax))
              return l
  
          k = -a / b
          m = -c / b
          for x in (xmin, xmax):
              y = k * x + m
              if y <= ymax and y >= ymin:
                  l.append((x,y))
  
          k = -b / a
          m = -c / a
          for y in (ymin, ymax):
              x = k * y + m
              if x < xmax and x > xmin:
                  l.append((x, y))
          return l
code_tokens: def __intersect ( self , rect , line ) : l = [ ] xmin , xmax , ymin , ymax = rect a , b , c = line assert a != 0 or b != 0 if a == 0 : y = - c / b if y <= ymax and y >= ymin : l . append ( ( xmin , y ) ) l . append ( ( xmax , y ) ) return l if b == 0 : x = - c / a if x <= xmax and x >= xmin : l . append ( ( x , ymin ) ) l . append ( ( x , ymax ) ) return l k = - a / b m = - c / b for x in ( xmin , xmax ) : y = k * x + m if y <= ymax and y >= ymin : l . append ( ( x , y ) ) k = - b / a m = - c / a for y in ( ymin , ymax ) : x = k * y + m if x < xmax and x > xmin : l . append ( ( x , y ) ) return l
short_docstring: Calculate the points of a line in a given rectangle
short_docstring_tokens: Calculate the points of a line in a given rectangle
comment: """ Calculate the points of a line in a given rectangle
  
              :param rect: Parameters of a rectangle (min x, min y, max x, max y).
              :type  rect: list of float
              :param line: line given as y=a*x+b or a*x+b*y+c=0
              :type  line: list of float
              :rtype: list of pairs of float
          """