original_docstring: Return a rectangle of equal area such that height / width < 2
docstring: Return a rectangle of equal area such that height / width < 2
docstring_tokens: Return a rectangle of equal area such that height / width < 2
code: def squish_rectangle(self):
      """Return a rectangle of equal area such that height / width < 2"""
      a, b, c, d = self.convex_hull()
      s1 = LineSegment(a, b)
      s2 = LineSegment(b, c)
      width = s1 if s1.length() < s2.length() else s2
      height = s2 if s1.length() < s2.length() else s1
      if height.length() > 2 * width.length():
          midp = height.midpoint()
          cut = height.to_line().perpendicular(midp)
          rec1, rec2 = self.split(cut)
          yield Shape(rec1.triangles + rec2.triangles)
          h1 = rec1.convex_hull()
          h2 = rec2.convex_hull()
          common = None
          for p in h1:
              for q in h2:
                  if float_eq(p[0], q[0]) and float_eq(p[1], q[1]):
                      common = q
                      break
              else:
                  continue
              break
          rec1 = rec1.rotate(common, math.pi)
          s = Shape(rec1.triangles + rec2.triangles)
          yield s
          for t in squish_rectangle(s):
              yield t
      else:
          yield self
code_tokens: def squish_rectangle ( self ) : a , b , c , d = self . convex_hull ( ) s1 = LineSegment ( a , b ) s2 = LineSegment ( b , c ) width = s1 if s1 . length ( ) < s2 . length ( ) else s2 height = s2 if s1 . length ( ) < s2 . length ( ) else s1 if height . length ( ) > 2 * width . length ( ) : midp = height . midpoint ( ) cut = height . to_line ( ) . perpendicular ( midp ) rec1 , rec2 = self . split ( cut ) yield Shape ( rec1 . triangles + rec2 . triangles ) h1 = rec1 . convex_hull ( ) h2 = rec2 . convex_hull ( ) common = None for p in h1 : for q in h2 : if float_eq ( p [ 0 ] , q [ 0 ] ) and float_eq ( p [ 1 ] , q [ 1 ] ) : common = q break else : continue break rec1 = rec1 . rotate ( common , math . pi ) s = Shape ( rec1 . triangles + rec2 . triangles ) yield s for t in squish_rectangle ( s ) : yield t else : yield self
short_docstring: Return a rectangle of equal area such that height / width < 2
short_docstring_tokens: Return a rectangle of equal area such that height / width < 2
comment: """Return a rectangle of equal area such that height / width < 2"""