import math


def anm_eccentric_to_mean(E:float, e:float, use_degrees:bool=False) -> float:
    """Convert eccentric anomaly into mean anomaly.

    Args:
        E (:obj:`float`): Eccentric anomaly. Units: *rad* or *deg*
        e (:obj:`float`): Eccentricity. Units: *dimensionless*
        use_degrees (bool): Handle input and output in degrees (Default: false)

    Returns:
        M (:obj:`float`): Mean anomaly. Units: *rad* or *deg*
    """

    # Convert degree input
    if use_degrees:
        E *= math.pi/180.0

    # Convert eccentric to mean
    M = E - e*math.sin(E)

    # Convert degree output
    if use_degrees:
        M *= 180.0/math.pi

    return M