original_docstring: Turns a right angle triangle into a rectangle (Shape).
      
      This function is a generator function that generates a Shape for every step
      needed to turn the triangle into a rectangle.
      
docstring: Turns a right angle triangle into a rectangle (Shape).
  This function is a generator function that generates a Shape for every step
  needed to turn the triangle into a rectangle.
docstring_tokens: Turns a right angle triangle into a rectangle ( Shape ) . This function is a generator function that generates a Shape for every step needed to turn the triangle into a rectangle .
code: def triangle2rectangle(tri):
      """Turns a right angle triangle into a rectangle (Shape).
      
      This function is a generator function that generates a Shape for every step
      needed to turn the triangle into a rectangle.
      """
      p = tri.points
      # The point at right angle
      right = tri.largest_angle()
      assert float_eq(tri.angle(right), math.pi / 2)
      other = [(right + 1) % 3, (right + 2) % 3]
      hyp = tri.segments[right]
      base = tri.segments[other[0]]
      height = tri.segments[other[1]]
      # We will cut the triangle at the midpoint of the height
      midp = height.midpoint()
      rect_side = base.to_line().parallel(midp)
      other_point = line_intersects_segment(rect_side, hyp)
      t1 = Triangle((p[other[0]], midp, other_point))
      t2 = Triangle((p[right], p[other[1]], midp))
      t3 = Triangle((p[other[1]], midp, other_point))
      yield Shape([t1, t2, t3])
      t1 = t1.rotate(other_point, math.pi)
      yield Shape([t1, t2, t3])
code_tokens: def triangle2rectangle ( tri ) : p = tri . points right = tri . largest_angle ( ) assert float_eq ( tri . angle ( right ) , math . pi / 2 ) other = [ ( right + 1 ) % 3 , ( right + 2 ) % 3 ] hyp = tri . segments [ right ] base = tri . segments [ other [ 0 ] ] height = tri . segments [ other [ 1 ] ] midp = height . midpoint ( ) rect_side = base . to_line ( ) . parallel ( midp ) other_point = line_intersects_segment ( rect_side , hyp ) t1 = Triangle ( ( p [ other [ 0 ] ] , midp , other_point ) ) t2 = Triangle ( ( p [ right ] , p [ other [ 1 ] ] , midp ) ) t3 = Triangle ( ( p [ other [ 1 ] ] , midp , other_point ) ) yield Shape ( [ t1 , t2 , t3 ] ) t1 = t1 . rotate ( other_point , math . pi ) yield Shape ( [ t1 , t2 , t3 ] )
short_docstring: Turns a right angle triangle into a rectangle (Shape).
short_docstring_tokens: Turns a right angle triangle into a rectangle ( Shape ) .
comment: """Turns a right angle triangle into a rectangle (Shape).
      
      This function is a generator function that generates a Shape for every step
      needed to turn the triangle into a rectangle.
      """$SEP$# The point at right angle$SEP$# We will cut the triangle at the midpoint of the height