import math


def sanitizeAngle(theta):
    """
    Returns an angle between 0 and 2pi.

    Parameters
    ----------
    theta : float
        an angle

    Returns
    -------
    theta : float
        an angle between 0 and 2*pi
    """

    if theta < 0:
        theta = theta + (1 + -1 * int(theta / (math.pi * 2.0))) * math.pi * 2.0

    if theta > 2.0 * math.pi:
        theta = theta - int(theta / (math.pi * 2.0)) * math.pi * 2.0

    return theta