docs: def calc_2d_ellipse_properties(cov,nstd=2):
      """Calculate the properties for 2d ellipse given the covariance matrix."""
      def eigsorted(cov):
          vals, vecs = np.linalg.eigh(cov)
          order = vals.argsort()[::-1]
          return vals[order], vecs[:,order]
  
      vals, vecs = eigsorted(cov)
      width, height = 2 * nstd * np.sqrt(vals[:2])
      normal = vecs[:,2] if vecs[2,2] > 0 else -vecs[:,2]
      d = np.cross(normal, (0, 0, 1))
      M = rotation_matrix(d)
      x_trans = np.dot(M,(1,0,0))
      cos_val = np.dot(vecs[:,0],x_trans)/np.linalg.norm(vecs[:,0])/np.linalg.norm(x_trans)
      theta = np.degrees(np.arccos(np.clip(cos_val, -1, 1))) # if you really want the angle
      return { 'width': width, 'height': height, 'angle': theta }, normal