# [Calculating celestial orbit with JavaScript] What is Kepler 6 elements?

In this post, I am going to share how to calculate the orbits and positions of celestial bodies that I learned while developing a solar system simulation with JavaScript.

Actually, I was not a good student in mathematics, so I will try to explain mathematical theories about this as easily as possible for other people like me.

Of course, you can search Google for a way to calculate the orbit or get a planet’s position. However, to understand this, you need to know about basic astronomy terms.

My friend said that we already learned about these terms when we were the first grade of high school. but unfortunately I could not remember these things…

So I decided I would study again from the beginning and started google hard.

## Let’s look at simple astronomical terms

Before looking at the Kepler 6 elements, let’s take a look at some simple terms used in astrophysics.

### Aphelion, Perihelion

Kepler said, all orbits of planets are ellipse. That means that every orbit has 2 focal points.

Usually, the star is positioned at the focal point of one of these. And aphelion means the most far focal point of the star, and perihelion means the most near focal point from the star.

If the orbit is a parabolic orbit, aphelion is infinite, there will be only one perihelion on the orbit.

### The celestial sphere

It means an imaginary sphere with a random radius around the observer.

### The celestial equator

The equator of the planet is projected onto the ecliptic. In the celestial sphere in the image above, the vertical line corresponds to thecelestial equator.

### The ecliptic

The orbital surface of the planet is projected onto the ecliptic. The Earth’s ecliptic is tilted from the equator by about the Earth’s axis of rotation (23.5 degrees.

### Right Ascension, Declination

Right ascension is measured in the direction that the star moves along the equator of the celestial sphere based on the vernal equinox point, and the unit is hours and minutes (1 hour is 15 degrees).

Declination is the angle measured from the celestial sphere’s equatorial plane to the star when the north of the celestial sphere is designated as `+`

and the south as `-`

, and it always has a value between +90 and -90.

For reference, the vernal equinox on the celestial sphere has both the right ascension and declination being `0`

.

### Ecliptic longitude, Ecliptic latitude

Ecliptic longitude and ecliptic latitude are the same concept as the right ascension and declination, but the reference plane is the ecliptic plane, not the equatorial plane of the planet.

### Orbital node, Ascending node, Descending node

Orbital node is the point where the orbital surface of the celestial body and the reference plane meet. The reference plane may vary by definition, and in the solar system, the reference plane is the orbital plane of the Earth.

Ascending node means that the astronomical object passes the reference plane to the north, and Descending node means the astronomical object passes the reference plane to the south.

## Kepler 6 elements

Now, let’s look at the Kepler 6 element that determines the shape, size, and direction of the orbit.

### Semi-major axis

Since the orbit of a planet is elliptical, it is defined as a semi-major axis and a semi-minor axis, not a radius.

Semi-major axis refers to a point farthest from the center of the orbit on the orbit, and Semi-minor axis means a point closest to the center of the orbit on the orbit.

The difference between these and the aphelion and the perihelion is that the point of measurement is the center of the orbit, not the star.

### Eccentricity

Eccentricity is the value of how distorted the ellipse is. In general, the eccentricity $e$ is defined as follows.

$e = \sqrt{1-k\frac{b^2}{a^2}}$In the above definition, $a$ is semi-major axis and $b$ is semi-minor axis. However, the eccentricity used in the Kepler orbit is slightly different.

$e = \sqrt{1+\frac{2EL^2}{m_\text{red}\alpha^2}}$The solution of this formula, $e$, is called the orbit eccentricity.

In the above definition, $E$ is the total orbital energy, $L$ is the angular momentum, $m_{red}$ is the converted mass, and $\alpha$ is the coefficient of the central force of the inverse square law.

The inverse square law means that a magnitude of a force is inversely proportional to the square of a distance. In this case, “force” means gravity.

However, I’m going to be using orbital data with orbital eccentricity, so I don’t really need to do this. It’s okay that just know the degree to which the general eccentricity formula differs from the orbital eccentricity.

The eccentricity of the Kepler orbit can be expressed in the following four forms.

- Circle orbit: $e = 0$
- Elliptical orbit: $0 < e < 1$
- Parabolic orbit: $e = 1$
- Hyperbolic orbit: $e > 1$

The eccentricity of the Earth’s orbit is about `0.0167`

, which is almost circular. Mercury, which has the highest eccentricity of all the solar system planets, has a value of `0.2056`

, which causes Mercury to receive twice as much solar radiation when in perihelion as in aphelion.

In fact, Pluto, who had an eccentricity of ‘0.248’, was the boss of this district, but as you all know, this poor friend was expelled from the solar system.(adios…)

Comets have a wide variety of eccentricities. Periodic comets usually have values from `0.2`

to `0.7`

, but comets orbiting very distorted have an eccentricity close to `1`

.

For example, Halley comet has an eccentricity of ‘0.967’, and its orbit is so distorted that it takes 76 years to orbit once. And Halley Comet’s next approach is 2061.

### Inclination

It is the slope between the star’s ecliptic plane and the orbit. If the Inclination exceeds `90`

, this means that the object is orbiting in the opposite direction to the object with Inclination 0~90.

### Longitude of Ascending Node

It means the right ascension to the point where the orbit crosses the ecliptic plane of the planet as the orbit passes from south(-) to north(+).

### Argument of periapsis

The angle from the perihelion to the ascending node determines the direction of the ellipse in the orbital plane. In other words, it means the declination from ascending node to perihelion.

### Perihelion passage time

The time at which the planet passed the perihelion of orbit.

I will try to make orbit of some planets with coding in next post.

- orbit of planets
- orbit
- Kepler orbital equation
- Kepler 6 elements
- JavaScript