### SLA_PV2EL

Orbital Elements from Position/Velocity

ACTION:
Heliocentric osculating elements obtained from instantaneous position and velocity.
CALL:
CALL sla_PV2EL (PV, DATE, PMASS, JFORMR, JFORM, EPOCH, ORBINC, ANODE, PERIH, AORQ, E, AORL, DM, JSTAT) 
##### GIVEN:
 PV D(6) heliocentric $\left[\phantom{\rule{0.3em}{0ex}}x,y,z,ẋ,ẏ,ż\phantom{\rule{0.3em}{0ex}}\right]$, equatorial, J2000 (AU, AU/s; Note 1) DATE D date (TT Modified Julian Date = JD$-$2400000.5) PMASS D mass of the planet (Sun = 1; Note 2) JFORMR I requested element set (1-3; Note 3)

##### RETURNED:
 JFORM I element set actually returned (1-3; Note 4) EPOCH D epoch of elements (${t}_{0}$ or $T$, TT MJD) ORBINC D inclination ($i$, radians) ANODE D longitude of the ascending node ($\Omega$, radians) PERIH D longitude or argument of perihelion ($\varpi$ or $\omega$, radians) AORQ D mean distance or perihelion distance ($a$ or $q$, AU) E D eccentricity ($e$) AORL D mean anomaly or longitude ($M$ or $L$, radians, JFORM=1,2 only) DM D daily motion ($n$, radians, JFORM=1 only) JSTAT I status: 0 = OK $-$1 = illegal PMASS $-$2 = illegal JFORMR $-$3 = position/velocity out of allowed range

NOTES:
(1)
The PV 6-vector is with respect to the mean equator and equinox of epoch J2000. The orbital elements produced are with respect to the J2000 ecliptic and mean equinox.
(2)
The mass, PMASS, is important only for the larger planets. For most purposes (e.g. asteroids) use 0D0. Values less than zero are illegal.
(3)
Three different element-format options are supported, as follows.

JFORM=1, suitable for the major planets:

 EPOCH = epoch of elements ${t}_{0}$ (TT MJD) ORBINC = inclination $i$ (radians) ANODE = longitude of the ascending node $\Omega$ (radians) PERIH = longitude of perihelion $\varpi$ (radians) AORQ = mean distance $a$ (AU) E = eccentricity $e$$\left(0\le e<1\right)$ AORL = mean longitude $L$ (radians) DM = daily motion $n$ (radians)

JFORM=2, suitable for minor planets:

 EPOCH = epoch of elements ${t}_{0}$ (TT MJD) ORBINC = inclination $i$ (radians) ANODE = longitude of the ascending node $\Omega$ (radians) PERIH = argument of perihelion $\omega$ (radians) AORQ = mean distance $a$ (AU) E = eccentricity $e$$\left(0\le e<1\right)$ AORL = mean anomaly $M$ (radians)

JFORM=3, suitable for comets:

 EPOCH = epoch of perihelion $T$ (TT MJD) ORBINC = inclination $i$ (radians) ANODE = longitude of the ascending node $\Omega$ (radians) PERIH = argument of perihelion $\omega$ (radians) AORQ = perihelion distance $q$ (AU) E = eccentricity $e$$\left(0\le e\le 10\right)$
(4)
It may not be possible to generate elements in the form requested through JFORMR. The caller is notified of the form of elements actually returned by means of the JFORM argument:
 JFORMR JFORM meaning 1 1 OK: elements are in the requested format 1 2 never happens 1 3 orbit not elliptical 2 1 never happens 2 2 OK: elements are in the requested format 2 3 orbit not elliptical 3 1 never happens 3 2 never happens 3 3 OK: elements are in the requested format
(5)
The arguments returned for each value of JFORM (cf. Note 5: JFORM may not be the same as JFORMR) are as follows:
 JFORM 1 2 3 EPOCH ${t}_{0}$ ${t}_{0}$ $T$ ORBINC $i$ $i$ $i$ ANODE $\Omega$ $\Omega$ $\Omega$ PERIH $\varpi$ $\omega$ $\omega$ AORQ $a$ $a$ $q$ E $e$ $e$ $e$ AORL $L$ $M$ - DM $n$ - -

where:

 ${t}_{0}$ is the epoch of the elements (MJD, TT) $T$ is the epoch of perihelion (MJD, TT) $i$ is the inclination (radians) $\Omega$ is the longitude of the ascending node (radians) $\varpi$ is the longitude of perihelion (radians) $\omega$ is the argument of perihelion (radians) $a$ is the mean distance (AU) $q$ is the perihelion distance (AU) $e$ is the eccentricity $L$ is the longitude (radians, $0-2\pi$) $M$ is the mean anomaly (radians, $0-2\pi$) $n$ is the daily motion (radians) - means no value is set
(6)
At very small inclinations, the longitude of the ascending node ANODE becomes indeterminate and under some circumstances may be set arbitrarily to zero. Similarly, if the orbit is close to circular, the true anomaly becomes indeterminate and under some circumstances may be set arbitrarily to zero. In such cases, the other elements are automatically adjusted to compensate, and so the elements remain a valid description of the orbit.
(7)
The osculating epoch for the returned elements is the argument DATE.
REFERENCE:
Sterne, Theodore E., An Introduction to Celestial Mechanics, Interscience Publishers, 1960.