# How to plot this orbit?

I have these data for some orbits, without any explanation about meaning of each datum:

{
"objects": [
{
"name": "Earth",
"id": "solar.planet.earth",
"elements": {
"q": 0.98322073104899
"a": 0.99920537923658
"node": 207.00538100359,
"e": 0.0159973600220234
"peri": 256.950444448438,
"incl": 0.0038067895470298
"T": 2459218.90577274
},
"position": {
"y": 0.9297659392321,
"z": -4.515675204152e-05,
"x": 0.3275590103186
}
},
{
"position": {
"z": 0.06029318307615,
"x": -0.4584994822692,
"y": 1.094698818492
},
"elements": {
"q": 0.806176191073582,
"a": 1.0323483836211,
"node": 75.5720068963318,
"e": 0.219085142318127,
"incl": 4.80809622578363,
"peri": 179.397909345983,
"T": 2459318.63483092
},
"id": "solar.minorplanet.98943",
"name": "2001 CC21"
},
{
"name": "1998 KY26",
"id": "solar.minorplanet.1998KY26",
"elements": {
"T": 2459001.17727408,
"incl": 1.48102189788285,
"peri": 209.372033608463,
"e": 0.201828518064676,
"node": 84.3664587661475,
"a": 1.23285180453922,
"q": 0.984027151835704
},
"position": {
"y": 1.407810076987,
"z": -0.002082322485705,
"x": 0.2198001273522
}
},
{
"name": "Hayabusa 2",
"id": "solar.spacecraft.hayabusa2",
"elements": {
"T": 2459212.01173911,
"incl": 5.99763881195244,
"peri": 205.214139025915,
"e": 0.187058473659886,
"node": 253.856900249799,
"q": 0.970678629676518,
"a": 1.19403253275367
},
"position": {
"z": 0.006301058519122,
"x": 0.3323137692169,
"y": 0.932379875888
}
}
],
"TT": 2459186.10708546,
"UTC": "2020-12-02T14:33:03"
}


I am trying to plot them in 3d in this JSFiddle, but I am proceeding randomly.... can anybody help?

The final result should be something like the one visible in the page which use these data (and in this page in English), but I want to represent it in 3d.

The accepted values for spacekit library are:

• initialValues.a Semimajor axis

• initialValues.e Eccentricity

• initialValues.i Inclination

• initialValues.epoch Epoch in JD

• initialValues.period Period in days

• initialValues.ma Mean anomaly

• initialValues.n Mean motion

• initialValues.L Mean longitude

• initialValues.om Longitude of Ascending Node

• initialValues.w Argument of Perihelion

• initialValues.wBar Longitude of Perihelion

Ok for incl, peri and node, I can make a guess for "a" ( initialValues.a - Semimajor axis ), "e" (initialValues.e - Eccentricity), but what about "q" and "peri"?

• initialValues.a Semimajor axis ---> "a"

• initialValues.e Eccentricity ---> "e"

• initialValues.i Inclination ---> "incl"

• initialValues.epoch Epoch in JD ---> "T"

• initialValues.period Period in days --->?

• initialValues.ma Mean anomaly --->?

• initialValues.n Mean motion --->?

• initialValues.L Mean longitude --->?

• initialValues.om Longitude of Ascending Node ---> "node"

• initialValues.w Argument of Perihelion ---> "peri"?

• initialValues.wBar Longitude of Perihelion ---> "peri"?

I also retrieved data from NASA Horizons for Earth to compare them to available ones, but I can't anyway figure out what "q" and "peri" match to:

• JD 2459218.905775463,
• A.D. 2021-Jan-04 09:44:19.0000,
• EC Eccentricity, e 0.01637
• QR Periapsis distance, q (km) 147092887 km
• IN Inclination w.r.t X-Y plane, i (degrees) 0.00285
• OM Longitude of Ascending Node, OMEGA, (degrees) 177
• W Argument of Perifocus, w (degrees) 284.4
• Tp Time of periapsis (Julian Day Number) 2459216 km
• N Mean motion, n (degrees/sec) 0.0001141
• MA Mean anomaly, M (degrees) 2.15
• TA True anomaly, nu (degrees) 2.22
• A Semi-major axis, a (km) 149541385 km
• AD Apoapsis distance (km) 151989883 km
• PR Sidereal orbit period (sec) 31540276 km

• "q": 0.98322073104899, Periapsis distance, q (AU) = 147087727 km
• "a": 0.99920537923658, Semi-major axis, a (AU) = 149478997 km
• "node": 207.00538100359,
• "e": 0.0159973600220234, Eccentricity, e
• "peri": 256.950444448438,
• "incl": 0.0038067895470298, Inclination w.r.t X-Y plane, i (degrees)
• "T": 2459218.90577274
• You may do 3 2D plots, the xy, yz and xz planes. But you may define other tilted planes not parallel to the x, y and z axis.
– Uwe
Dec 3, 2020 at 14:48
• Proceeding randomly I updated my JSFiddle, by assigning "q" and "peri" to Mean Anomlay and Argument of Perihelion... who know if it's right?? jsfiddle.net/spacexplorer2020/6cqdLhzj/20 Dec 9, 2020 at 8:49
• it looks like redundant data are provided: using the formula suggested in @Ryan C answer for periapsis distance ( =a(1-e) ), I get for hayabusa: 1.19403253275367 * (1-0.187058473659886 ) = 0,970678629676520 , which is really close to the value provided as "q" ( 0.970678629676518 ) Dec 9, 2020 at 9:37

## 3 Answers

Work in progress, new figures will follow.

I took the orbit data of Hayabusa2 we got to plot the magenta ellipse. I used the initialValues.a Semimajor axis and initialValues.e Eccentricity. The two red dots are the foci of the ellipse.

The blue dot is the one position of Hayabusa2 we got, only x and y were used.

Sun is at the center x = 0 and y = 0, of course one focus point is there too.

Then I rotated the ellipse by the node": 253.856900249799 angle to get the green angle. The one and only position of Hayabusa (blue dot) is now on the rotated ellipsis but not on the magenta ellipse.

I added the axes, the lines in magenta are the axes of the ellipse (magenta too) aligned to the coordinate system. The green lines are the rotated axes belonging to the green ellipse. The 'x' markers in magenta are the foci of the unrotated ellipse. The x marker at the origin is one focus of the green rotated ellipse too. The black arc shows the node angle. I added some annotations.

In the next step this 2D plane should be inserted to the 3D plot. The Sun should be at the center for 2D and 3D plot. Hayabusa2 should be at the given xyz position. The "incl": 0.0038067895470298, Inclination w.r.t X-Y plane, i (degrees) should be correct too.

But we need 3 points to define the correct orientation of the plane. We may look if the Earth orbit may be used for some additional information. But we should have a time when both Earth and Hayabusa are at the same location. Crossing the Earth orbit alone would not help when Earth is far away from that point when Hayabusa is there. The two small bodies should be close to the Hayabusa orbit too.

The 3D plot to include the 2D plot above.

• rad carefully the question: "I am trying to plot it in this JSFiddle" (it's javascript, you answered with python) and "I can't anyway figure out what "q" and "peri" match to:" (and you don't mention "q" and "peri") Dec 7, 2020 at 16:12
• additionally, "solar.spacecraft.hayabusa2" is not a planet, and you load planets data from de421.bsp file, not from my file. Dec 7, 2020 at 16:16
• I don't need data from other sources, I need to plot the data provided in my question. Dec 8, 2020 at 10:15
• it looks like there is no solution to this problem, due to lack of data (we actually have only 5 orbital elements, so orbits can only plotted in 2d, see my answer) Dec 9, 2020 at 10:17
• Plotting the axes is a very good idea, I will do it next.
– Uwe
Dec 10, 2020 at 8:17

You need to learn a little about the many ways in which orbit data can be represented, starting from a basic tutorial like https://en.wikipedia.org/wiki/Orbital_elements

One of the important things to keep in mind is there are no more than six independent numbers out of that set, but not just any six can be chosen. If you input values for too many, things will go wrong because they won't be consistent with each other. For example, if you have semi-major axis $$a$$ and eccentricity $$e$$, then by definition periapsis distance is $$a(1-e)$$ and apoapsis distance is $$a(1+e)$$, so specify no more than two of those four or you invite problems. Similarly, mean motion, period, and semi-major axis are all redundant with each other, assuming you know which body is being orbited (because the conversion involves its mass). True anomaly, mean anomaly, and time since perigee passage or other reference epoch are another set from which you should choose at most one to be an input.

The traditional order of the Keplerian orbital elements is semi-major axis $$a$$, eccentricity $$e$$, inclination $$i$$, right ascension of the ascending node (RAAN) $$\Omega$$, argument of periapsis $$\omega$$, and true anomaly $$\nu$$. Be aware that some of these definitions break down if some of the others take on certain values. For example, if inclination is exactly zero, then there isn't an ascending node so it doesn't have an $$\Omega$$, but that still specifies the orbit plane uniquely. Similarly, if eccentricity is exactly zero, then there isn't a periapsis (all points are the same distance from the center, because the ellipse with $$e=0$$ is a circle), so you need to define $$\varpi$$ rather than $$\omega$$ to say where to start measuring $$\nu=0$$.

• this is an interesting explanation, but not an answer to my question. Dec 6, 2020 at 17:58

It looks like there is not a possible answer to this question: the available data are not enough to plot a 3d orbit. Although there are apparently 6 orbital elements, they are actually just 5; indeed these three data are provided:

 - "e": 0.187058473659886
- "a": 1.19403253275367
- "q": 0.970678629676518


But:

 periapsis distance = a * ( 1 - e) = 1.19403253275367 * (1 - 0.187058473659886 )
= 0,970678629676520


So as a matter of fact we have only 5 orbital elements:

 - "incl": 5.99763881195244,
- "peri": 205.214139025915,
- "e": 0.187058473659886,
- "node": 253.856900249799,
- ("q": 0.970678629676518,)  <<<====== can be calculated from a and e
- "a": 1.19403253275367


They are not enough to plot 3d orbit; the original page using these data only plots orbits in 2d; by reversing engineering the source code we can see the "q" parameter is not used at all:

key: "calcEllipse",
value: function calcEllipse(object) {

////// "a" and "e"//////
var cx = -factor * object.elements.a * object.elements.e;
var cy = 0;
var rx = factor * object.elements.a;
var ry = factor * object.elements.a * Math.sqrt(1 - Math.pow(object.elements.e, 2));

////// "node", "incl" and "peri" //////
var transform = "\n              rotate(".concat(-1.0 * object.elements.node, ")\n
scale(1.0, ").concat(Math.cos(object.elements.incl / 180 * Math.PI), ")\n
rotate(").concat(-1.0 * object.elements.peri, ")");
return {
cx: cx,
cy: cy,
rx: rx,
ry: ry,
transform: transform


Passing just 5 parameters to spacekit.js library results in error:

NaN position value - you may have bad or incomplete data in the following ephemeris:
a: 0.937550412197935,
e: 0.140879661549663,
i: 0.0748349916816544,
om: 1.2865260962475196,
w: 2.0673222342313817

• It was a bit hard to read. I improved the formatting. Dec 10, 2020 at 3:22
• I didn't use "code formatting" for a reason: because it does not allow using bold for text; by just adding "code formatting" you caused a little mess due to wandering asterisks here and there... I had to delete them and replace them by comments which are not present in original source code. Dec 10, 2020 at 8:11
• The difference between the two numbers "q": 0.970 678 629 676 518 and periapsis distance = 0,970 678 629 676 520 are no problem I think. Double precision floating point 64 bit numbers have from 15 to 17 significant decimal digits precision. So a difference of 0.000 000 000 000 002 is tolerable.
– Uwe
Dec 10, 2020 at 9:56
• @Uwe Of course it is not a problem: this is why I wrote that we actually have 5 rather than 6 parameters: because the q provided is useless, as we can calculate it from a and e. Dec 11, 2020 at 10:34
• @jumpjack although it might not solve the "bold font" for text issue, consier adding an answer to Activate Language Sensitive Highlighting for code/script blocks? in meta and upvoting everywhere if you think it's a good idea?
– uhoh
Feb 6, 2021 at 5:34