code: def extents(triangles, areas=None):
      
      triangles = np.asanyarray(triangles, dtype=np.float64)
      if not util.is_shape(triangles, (-1, 3, 3)):
          raise ValueError('Triangles must be (n,3,3)!')
  
      if areas is None:
          areas = area(triangles=triangles,
                       sum=False)
  
      # the edge vectors which define the triangle
      a = triangles[:, 1] - triangles[:, 0]
      b = triangles[:, 2] - triangles[:, 0]
  
      # length of the edge vectors
      length_a = (a**2).sum(axis=1)**.5
      length_b = (b**2).sum(axis=1)**.5
  
      # which edges are acceptable length
      nonzero_a = length_a > tol.merge
      nonzero_b = length_b > tol.merge
  
      # find the two heights of the triangle
      # essentially this is the side length of an
      # oriented bounding box, per triangle
      box = np.zeros((len(triangles), 2), dtype=np.float64)
      box[:, 0][nonzero_a] = (areas[nonzero_a] * 2) / length_a[nonzero_a]
      box[:, 1][nonzero_b] = (areas[nonzero_b] * 2) / length_b[nonzero_b]
  
      return box
docs: Return the 2D bounding box size of each triangle.
  
      Parameters
      ----------
      triangles : (n, 3, 3) float
        Triangles in space
      areas : (n,) float
        Optional area of input triangles
  
      Returns
      ----------
      box :  (n, 2) float
        The size of each triangle's 2D oriented bounding box