Below are some methods of computing the length of an elliptical orbit, though the methods tend
to fall apart for highly elliptical orbits (like comets), but work fine for most planets and
asteroids (e.g. when the ecentricity is close to 0). The most precise method would be a numerical
solution, itterating ephemeris at short time steps over the period of the body, adding up the short
line segments. The infinite series includes an "n Choose r" function, which uses factorials, so the
limit of double floating point precision is hit fairly quickly. Code at the bottom can pre-generate
code for any given number of terms, saving computation time at runtime.
P is the perimeter, a is the semi-major axis and b is the semi-minor axis.