This second tutorial explains how you can create your own Saturnian System simulation or "orrery" using simple JavaScript. The end result will feature all the major Saturnian moons (including Titan) in their orbits around Saturn based on a Gregorian input date. And the concepts tought here can also be applied to create a simulation for the Jovian System or even one for our own Moon. The only difference is swapping out the Keplerian Elements and Rates.

This Saturian System tutorial builds upon the first tutorial, which explains how to create your own JavaScript Solar System simulation. If you haven't followed that JS tutorial yet, we recommend to do that first: TUTORIAL - PLANETS

# I. KEPLERIAN ELEMENTS FOR SATELLITES

Just like in the previous tutorial, we will again rely on JPL's Keplerian Elements and Rates for the natural satellites of Saturn. They can found in the Planetary Satellite Mean Orbital Parameters webpage.
The only problem is that the last two elements; the LONGITUDE OF PERIHELION (ϖ) and MEAN LONGITUDE (L) are not given. We will need to calculate them based on other information in the JPL table. See below Keplerian Elements for Titan:

 I. ORBIT SIZE (a0) II. ORBIT SHAPE (e0) III. ORBIT INCLINATION (i0) IV. LONGITUDE OF ASCENDING NODE (Ω0) V. LONGITUDE OF PERIHELION (ϖ0) VI. MEAN LONGITUDE (L0) 1,221,865km 0.0288 0.306° 28.060° CALCULATE CALCULATE

Since the Argument of Perihelion and the Longitude of the Ascending Node are given on the JPL webpage, we can calculate the LONGITUDE OF PERIHELION using this basic JavaScript function:
``````
//LONG. PERIHELION(W) =
//ARG. PERIHELION(w) + LONG. ASC. NODE(☊)

function calcLPeri(argPeri, longAscNode) {
return (argPeri + longAscNode) % 360;
}
``````

And we can also calculate the MEAN LONGITUDE using this JavaScript function:
``````
//MEAN LONGITUDE(L) =
//ARG. PERIHELION(w) + LONG. ASC. NODE(☊) + MEAN ANOMALY(M)

function calcMeanL(argPeri, longAscNode, meanAnom){
return (argPeri + longAscNode + meanAnom) % 360;
}
``````

After doing these calculations, see below the complete set of Keplerian Elements for the moon Titan:

 I. ORBIT SIZE (a0) II. ORBIT SHAPE (e0) III. ORBIT INCLINATION (i0) IV. LONGITUDE OF ASCENDING NODE (Ω0) V. LONGITUDE OF PERIHELION (ϖ0) VI. MEAN LONGITUDE (L0) 1,221,865km 0.0288 0.306° 28.060° 208.592° 11.902°

# II. KEPLERIAN RATES FOR SATELLITES

Now that we have successfully calculated all six Keplerian Elements, we need to also know the Keplerian Rates for the Satellite in question. Based on the JPL webpage, we know this:

 I. ORBIT SIZE (a1) II. ORBIT SHAPE (e1) III. ORBIT INCLINATION (i1) IV. LONGITUDE OF ASCENDING NODE (Ω1) V. LONGITUDE OF PERIHELION (ϖ1) VI. MEAN LONGITUDE (L1) #N/A #N/A #N/A 704.60 yr 352.12 yr 22.58 deg/day

As you can see, we do not know the rates for the ORBIT SIZE, ORBIT SHAPE and ORBIT INCLINATION. For this simulation we will therefore assume they are all 0. For the purposes of this simulation that is good enough.
Next to that, to convert the rates for LONGITUDE OF ASCENDING NODE and LONGITUDE OF PERIHELION to a 100-year rate, we use the following JavaScript function:
``````
//LONG. PERIHELION RATE = (100 YEARS / ARG. PERIHELION RATE (YEARS)) * 360 DEGREES
//LONG. ASC. NODE RATE = (100 YEARS / LONG. ASC. NODE RATE (YEARS)) * 360 DEGREES

function calcCenturyRate(rate){
return (100/rate) * 360;
}
``````

Finally, to calculate the MEAN LONGITUDE rate, we multiply the daily rate by 100 years (=36,525 days):
22.58 deg/day * 36,525 days = 824,624 degrees/century

Now see below the complete set of Keplerian Rates for the moon Titan:

 I. ORBIT SIZE (a1) II. ORBIT SHAPE (e1) III. ORBIT INCLINATION (i1) IV. LONGITUDE OF ASCENDING NODE (Ω1) V. LONGITUDE OF PERIHELION (ϖ1) VI. MEAN LONGITUDE (L1) 0km/cty 0/cty 0°/cty 51.09°/cty 102.24°/cty 824,624°/cty

# III. ADJUST FOR SATURN MEAN LONGITUDE RATE

There is one more thing we need to do to make the rates correct. And that is to adjust the MEAN LONGITUDE of each of the moons based on the amount of degrees Saturn has rotated around the sun since the epoch J2000 (January 1, 2000 12:00 UTC):

MEAN LONGITUDE MOON -= MEAN LONGITUDE RATE SATURN * CENTURIES SINCE J2000

Saturn takes roughly 29.45 years to complete a full orbit around the sun. Based on the formula given above, when the Gregorian date is January 1, 2000, this MEAN LONGITUDE adjustment is 0°. But when the year is 2015, Saturn has completed half the orbit since J2000. Which means the adjustment is about 180°.

# IV. COMPLETE JAVASCRIPT ORRERY

The finished JS Moon Simulation with all seven major moons of the Saturnian System can be seen on the right. The moons in order:
• MIMAS