Calculating orbiting body's position at a given time T
Creating an orbit for a planet and place the planet on it
To create a planetary orbit and place a planet on it so that one can calculate precise position of the planet at a given time can be done by using Orbital Elements. You can read detailed information about them from this wikipedia page. In this guide, I will show detailed steps on how to do the calculation and implement it in Blender or Unity.
There are six parameters in orbital elements that are closely related to the 3-D positions and 3-D velocity of a planet.
- semi-major axis ($a$): determines the size of an orbit. For a given mass of the central object (e.g., Sun), $a$ is directly related to an orbital period ($P$) through Kepler's 3rd law.
- eccentricity ($e$): shape of the ellipse. In an elliptical orbit, Sun is located at one of two foci.
- inclination ($i$): the tilt angle of the orbital plane with respect to observer's line of sight.
- longitude of the ascending node ($\Omega$): In an inclined orbit (i.e., non-zero $i$), there are two points where a planetary orbit crosses the plane of reference. We choose one of these points as $\Omega$ where a planet moves from below the reference planet to above the plane.
- argument of periapsis ($\omega$): determines the orientation of the ellipse in the orbital plane. From the focus where the Sun is located at, the direction toward the periapsis can be anywhere on the plane. An angle measured from the ascending node to the periapsis can fix the orientation of the ellipse.
- true anomaly ($\nu$): the position of the planet measured in angle from the periapsis for a given time (or epoch).
Calculation
Check the Wikipedia for “Orbit Modeling” for useful information.
From a given set of orbital elements, let's see how we can calculate the planet's position at a given time $T$. At any arbitrary epoch (say $T=0$), orbital elements can be expressed as $(a_0,e_0,i_0,\Omega_0,\omega_0,\nu_0)$. Since the first five parameters do not change over time (without a perturbation like additional object), at a later time ($T+\delta T$), we only need to find the new $\nu$; i.e., at $T=T+\delta T \equiv new$, we have $(a_0,e_0,i_0,\Omega_0,\omega_0,\nu_{new})$ where $\nu_{new}=\nu_0 + \delta\nu$.
In this calculation, the reference plane is denoted as $(\hat{I},\hat J,\hat K)$ where $\hat I$ is the direction toward the vernal equinox and the orbital plane is denoted as $(\hat x,\hat y,\hat z)$ where $\hat x$ is toward the periapsis and $\hat z$ is toward the north pole. In the Solar System, we choose the ecliptic plane as the reference plane.
Then, the transformation between the reference plane and the orbital plane is defined by three Euler rotations.
Step by step calculation tutorial
See this PDF file for the step-by-step calculations.