[Simulating Celestial Bodies with JavaScript] Understanding the Keplerian Elements
A Guide to Keplerian Orbital Elements Without Needing Astronomy or Math Expertise
![[Simulating Celestial Bodies with JavaScript] Understanding the Keplerian Elements [Simulating Celestial Bodies with JavaScript] Understanding the Keplerian Elements](/static/746a090a9954b09cea8d75079269697d/2c11c/thumbnail.jpg)
In this post, we’ll explore how to calculate the orbits and positions of celestial bodies, a topic I found particularly challenging while developing a solar system simulation. As someone who struggled with math in high school, I aim to simplify these concepts for others with similar experiences.
While there are numerous resources online about plotting orbits and estimating planetary positions, most require a solid understanding of basic astronomical terms. I had to revisit these concepts because my knowledge from high school astronomy classes was practically nonexistent.
I’m not an astrophysics expert, just a developer, so there may be inaccuracies in my explanations.
Understanding Coordinates and Reference Planes
Since celestial bodies move in a three-dimensional space, a reference coordinate system is essential to describe their motion. This includes deciding the center point of the coordinates and determining what should be considered 0° when measuring angles.
The Celestial Sphere and the Ecliptic
The celestial sphere is an imaginary sphere of infinite radius centered on the observer. Here, the observer typically refers to Earth, as most human observations are Earth-based. The celestial equator is the projection of Earth’s equator onto the celestial sphere.

In the diagram, the yellow line represents the ecliptic, which is the apparent path the Sun traces across the sky as observed from Earth. This concept originates from the geocentric model but is still useful for defining positions of celestial objects relative to Earth.
Due to the 23.5° tilt of Earth’s rotational axis, the celestial equator and the ecliptic intersect at an angle of 23.5°. The Sun appears to move northward at the vernal equinox and southward at the autumnal equinox from Earth’s perspective.
In modern astronomy, we recognize that Earth orbits the Sun, so the ecliptic becomes the reference plane, while the celestial equator is tilted.
Right Ascension and Declination
The celestial sphere allows us to define the positions of celestial objects using right ascension (RA) and declination (Dec). These are analogous to longitude and latitude on Earth.
Right Ascension (RA): Measures the eastward angle from the vernal equinox along the celestial equator. RA is expressed in hours, minutes, and seconds, where 1 hour corresponds to 15°.
Declination (Dec): Measures the angular distance north (+) or south (-) of the celestial equator, ranging from -90° to +90°.
With these two values, we can pinpoint any object on the celestial sphere. However, the distance to the object is not defined in this system.
Orbital Terminology
Ascending Node / Descending Node
A celestial body’s orbital plane often intersects a reference plane (e.g., the ecliptic). The ascending node is where the body moves from south to north of the reference plane, and the descending node is where it moves from north to south.
For instance, Pluto’s orbit shows how it crosses above and below the ecliptic plane:

Aphelion / Perihelion
In an elliptical orbit, the aphelion is the farthest point from the central star, while the perihelion is the closest. Parabolic orbits only have a perihelion, as their aphelion is at infinity.
Keplerian Elements
The Keplerian elements define the shape, size, and orientation of an orbit. These include:
- Semi-major axis (a): Describes the size of the orbit.
- Eccentricity (e): Describes the orbit’s shape.
- Inclination (i): Describes the tilt of the orbital plane.
- Longitude of the Ascending Node (Ω): Specifies the location of the ascending node.
- Argument of Periapsis (ω): Describes the orientation of the elliptical orbit within the orbital plane.
- Time of Periapsis Passage (T): Marks the time when the body is closest to the central star.
Semi-major Axis
The semi-major axis (a) is the longest radius of an elliptical orbit. It defines the orbit’s size and is directly related to the orbital energy.

Unlike the aphelion or perihelion, the semi-major axis measures the average distance of the orbit, making it essential for energy calculations.
Eccentricity

Eccentricity (e) quantifies the shape of an orbit:
Here, is the semi-major axis, and is the semi-minor axis. For Keplerian orbits, eccentricity is influenced by gravitational forces and is given by:
Where:
- : Total energy
- : Angular momentum
- : Reduced mass
- : Force constant for the inverse-square law (e.g., gravity)

Orbital types based on eccentricity:
- Circular:
- Elliptical:
- Parabolic:
- Hyperbolic:
Earth’s orbit has an eccentricity of ~0.0167
, making it nearly circular.
Inclination
Inclination (i) is the angle between the orbital plane and the reference plane. An inclination >90° indicates retrograde motion.
Longitude of the Ascending Node
This is the angle from the vernal equinox to the ascending node, measured along the reference plane.
Argument of Periapsis
The argument of periapsis (ω) is the angle from the ascending node to the periapsis, measured within the orbital plane. It determines how the elliptical orbit is oriented relative to the reference plane.
Time of Periapsis Passage
This marks when the celestial body passes through the periapsis, allowing us to calculate its position at any given time.
Conclusion
In the next post, we’ll implement orbital calculations in code. For now, this concludes the glossary of basic astronomical terms and an introduction to the Keplerian elements.