import math


def E2M(Ecc, e):
    """
    Function: E2M
    Purpose: Maps the eccentric anomaly angle into the corresponding
        mean elliptic anomaly angle.  Both 2D and 1D elliptic
        orbit are allowed.
    Inputs:
        Ecc = eccentric anomaly (rad)
        e = eccentricity (0 <= e < 1)
    Outputs:
        M = mean elliptic anomaly (rad)
    """
    if e >= 0.0 and e < 1.0:
        M = Ecc - e * math.sin(Ecc)
        return M
    raise ValueError('Error: E2M() received e = {}, the value of e should be 0 <= e < 1'.format(str(e)))