def perapo2aecc(r_per, r_apo):
    """Apoapsis/Periapsis to Semi-major axis and Eccentricity

     a, p, ecc = perapo2aecc(r_per,r_apo)

    Inputs: 
    - r_per - periapsis distance in km
    - r_apo - apoapsis distance in km

    Outputs: 
    - a - semi-major axis in km
    - ecc - eccentricity

    Dependencies: 
    - none

    Author: 
    - Shankar Kulumani 19 Sept 2012
    - list revisions
    - Shankar Kulumani 31 Oct 2012
    - added semi-latus rectum
    - Shankar Kulumani 2 Oct 2017
        - convert to Python

    References
    - AAE532 Notes/PS5
    """
    ecc = (r_apo - r_per) / (r_per + r_apo)
    a = r_per / (1 - ecc)
    p = a * (1 - ecc ** 2)
    return a, p, ecc
