import math


def vector_to_r_theta(px, py, pz, aperture):
    """
    This function converts a coordinate on a sphere, to r, theta in projection. What we have is an axis, y axis that is
    where our lens is pointing to, and r defines the angle of y axis to the point p which is defined by px, py, pz.
    Theta is the rotation of the point p on y axis. Note: P = (Px, Py, Pz), |P| = 1.

    Args:
      px: x of 3D point
      py: y of 3D point
      pz: z of 3D point

    Return:
      r: r, Angle of PO and y axis
      theta: Rotation of point p on y axis.
    """
    r = 2 * math.atan2(math.sqrt(px*px + pz*pz), py)/aperture
    theta = math.atan2(pz, px)
    return r, theta