Your browser does not support HTML5 Canvas. Please update your browser.
HOME
KEPLER
GLOSSARY
JAVASCRIPT TUTORIALS
TOOLS
ABOUT

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

I. RECAP ON CALCULATING KEPLERIAN ELEMENTS

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

II. CALCULATE RA & DECLINATION PLANETS

The additional steps required to calculate RA & DECLINATION for the planets (used for observations from Earth):
  1. CALCULATE GEOCENTRIC ECLIPTIC COORDINATES
  2. By subtracting the Earth's coordinates for the planet in question, you change the origin of coordinate system.
  3. CALCULATE GEOCENTRIC EQUATORIAL COORDINATES
  4. By taking into account the Earth's axial tilt of 23.43928° at J2000, we change the coordinate system again.
  5. CALCULATE RIGHT ASCENSION (R.A.)
  6. Now calculate RIGHT ASCENSION angle (and convert to hours, minutes, seconds if desired).
  7. CALCULATE DECLINATION
  8. Finally, also calculate angle of DECLINATION (and convert to degrees, minutes, seconds if desired).
By looking at the complete source code of this tutorial, you will see all these steps executed in the described order. Credits for the calculations in this section go to Keith Burnett and David Colarusso.

III. CALCULATE RA & DECLINATION SUN

Now that we've done most of the work, there is one thing left to do. That is to calculate RA & DECLINATION for the sun. Since the sun is at the center of our solar system, HELIOCENTRIC ECLIPTIC COORDINATES of 0,0,0 can be used. Use that as the "planet" input when calculating (9), (10), (11) & (12) for the sun.

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

IV. COMPLETE JAVASCRIPT ORRERY

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.
Your browser does not support HTML Canvas. Please update your browser.
Completed JavaScript simulation of RIGHT ASCENSION and DECLINATION for planets and sun based on input date