Solution (source code)

= Solution

Choose zero gravitational <potential energy> at infinite separation. The spacecraft's conserved total <orbital energy> is
$$
\boxed{E=\frac12mv_p^2-\frac{GMm}{r_p}
=\frac12mv_a^2-\frac{GMm}{r_a}.}
$$
At <periapsis> and <apoapsis>, the radial <velocity> vanishes, so the <velocity> is perpendicular to the radius. The conserved <angular momentum> magnitude is therefore
$$
\boxed{J=mr_pv_p=mr_av_a.}
$$
The <angular momentum> vector is normal to the fixed orbital plane. The respective units are joules and $\mathrm{kg\,m^2\,s^{-1}}$. These expressions use Newtonian <gravity> and the approximation $M\gg m$.