This tutorial explains how to calculate RIGHT ASCENSION (R.A.) & DECLINATION for the planets in the solar system and the sun using the Keplerian Elements.
The JS simulation will also use these calculated Celestial Coordinates to plot the Sun and the other planets on the Celestial Sphere.

This 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

**CALCULATE JULIAN DATE**
First we took a Gregorian input date and converted it to a Julian Date.
**GET KEPLERIAN ELEMENTS FROM JPL**
Then we extracted the Keplerian Elements for the planets in our solar system for J2000 from the JPL website.
**CALCULATE KEPLERIAN ELEMENTS FOR DATE**
By combining (1) and (2), we can now calculate each of the planet's six Keplerian Elements for the input date.
**CALCULATE MEAN ANOMALY**
Now calculate MEAN ANOMALY, which is the angle measured from point of Perihelion if in circular orbit.
**CALCULATE ECCENTRIC ANOMALY**
Now resolve Kepler's Equation through an iterative method to get ECCENTRIC ANOMALY.
**CALCULATE TRUE ANOMALY**
Now calculate TRUE ANOMALY to get actual position of planet.
**CALCULATE RADIUS VECTOR**
Calculate the distance from the planet to the sun.
**CALCULATE HELIOCENTRIC ECLIPTIC COORDINATES**
Finally we can now calculate X, Y & Z coordinates of the planets on the Ecliptic Plane to use in our simulation.

**CALCULATE GEOCENTRIC ECLIPTIC COORDINATES**
By subtracting the Earth's coordinates for the planet in question, you change the origin of coordinate system.
**CALCULATE GEOCENTRIC EQUATORIAL COORDINATES**
By taking into account the Earth's axial tilt of 23.43928° at J2000, we change the coordinate system again.
**CALCULATE RIGHT ASCENSION (R.A.)**
Now calculate RIGHT ASCENSION angle (and convert to hours, minutes, seconds if desired).
**CALCULATE DECLINATION**
Finally, also calculate angle of DECLINATION (and convert to degrees, minutes, seconds if desired).

Following the 12 steps described above, allow you to calculate the Celestial Coordinates for the planets and the sun.

The finished simulation on the right shows not only the calculated values for RIGHT ASCENSION and DECLINATION, but also demonstrates how the planets and sun move across the sky over time.

The apparent "sine wave" motion is caused by the axial tilt of the Earth (see "*PATH OF SUN ACROSS SKY*" section in GLOSSARY).

Get the full JavaScript source code HERE.

You can also verify the RIGHT ASCENSION and DECLINATION values using NASA's HORIZONS Web-Interface. Make sure to set the Observer Location to "*Earth-Moon Barycenter*" for comparison.

The apparent "sine wave" motion is caused by the axial tilt of the Earth (see "

Get the full JavaScript source code HERE.

You can also verify the RIGHT ASCENSION and DECLINATION values using NASA's HORIZONS Web-Interface. Make sure to set the Observer Location to "