d13

Calculating elliptical planet orbits

Recommended Posts

Hi Everyone!

I'm bust building a semi-realistic solar system model.

I found this example extremely helpful: 

http://www.babylonjs-playground.com/#1UGDQC#5

But, I have a question about how calculate realistic elliptical orbits.

I know that an ellitical orbit can be calculated by modifying this line of code:

planet.position = new BABYLON.Vector3(10 * Math.sin(alpha), planet.parent.position.y, 10 * Math.cos(alpha));

 

And, the eccentricity of each planet is well documented:

http://www.enchantedlearning.com/subjects/astronomy/glossary/Eccentricity.shtml

I know that an ellitical orbit can be calculated by modifying this line of code:

But what I don't yet know is how calculate an ellipse based on those numbers.

Can anyone help?

 

Thanks!

Share this post


Link to post
Share on other sites

Thanks Jerome!

In trying to come up with realistic orbits I need to somehow incorporate the actual eccentricity data.

For example, Earth's is 0.017.

My guess is that I should integrate it something like this?

planet.position = new BABYLON.Vector3((10 - 0.017) * Math.sin(alpha), planet.parent.position.y, 10 * Math.cos(alpha));

 

Share this post


Link to post
Share on other sites

Hey d13/others... if a more-finished playground version of that solar system... ran across the forum floor and pooped on my shoe... I wouldn't mind at all.  :)

thx.  That would be a VERY popular playground, I suspect.  If it uses elevation data to form the planets, it will surely earn a slot on the BJS Main Website demos.

And that means... a party!  YAY!

Share this post


Link to post
Share on other sites

@Wingnut

Hey :D

An alpha version is more or less working now:
https://www.bitofgold.com/solarsystem/

Saturn has no rings (yet), and it's hard to position the sky to the correct rotation. (the earth axis is near  the north star, but other stars are not perfectly in the right direction...)
I used only CC or free texture maps.

I always wanted to do a planetarium or solar system model. It took less than a day. BABYLON is awesome!

 

ssystem2.jpg

Share this post


Link to post
Share on other sites

Hi d13!  First, may I say that I love this topic.  I'm enjoying EVERYONE's comments and demos, and I am learning TONS!  You guys are interesting and FUN!!!

Others will surely have other implementation opinions, but in MY opinion... I'd say start-with a big bottle of Jack Daniel's Tennessee Sippin'-Whiskey.  Yum.  :)  Perhaps some herbal enjoyments, too.  (shhh)  ;)

Next, say the term "DEM" a few times... see how it feels.  "DEM" will soon control your "worlds".  ;)

Perhaps, visit here.  https://earthdata.nasa.gov/community/community-data-system-programs/measures-projects/nasadem

Ok, that's some basic info about DEM... written by DEM-guys.  ;)

Ok, next, let's go to Mercury.  https://www.melown.com/mercury/?pos=obj,-61.627417,7.456315,fix,-35.19,123.56,-13.42,0.00,58772.15,55.00

Notice that... "bumpy-ness" can be simulated via texture colors/baked shadows... at ANY higher altitudes above the planet.  Not until the camera is placed in a low-altitude position with the horizon-line in-view... do we see the planet's TRUE heightMap elevation data (its bumps).  So, although "a purist" would want to use THE BEST resolution DEM data that NASA will give us for free... and have each planet pre-rendered max-rez at the beginning of the scene-start, it might not be wise to do so (practically speaking).

This might be a great use for "incremental loading"... or incremental LODing.  :)  With me?  If so, have another shot of booze, cuz you ain't drunk enough, yet.  heh.

One last thing.  You can be SURE that a couple thousand other demented 3D scientists... have already tried to do this.  (This solar system is a rather popular subject, worldwide.  Maybe more popular than BJS!)   SO... there is certainly code to steal, hidden in various worldwide dumpsters (neglected folders).  But perhaps more importantly, there are already JSON files containing planetary DEM data for ALL nearby NASA-noticed planets... freely available. 

Where?  I dunno.  You need to go fishing.  Put various pertinent keywords onto your hook, and cast into the logs and lily pads... where "big fish" hang-out.  :)

It might not be SUPER hi-rez data, but it is "reasonable" and manageable.  And there's surely more than one resolution available, too.... for each planet.  Some planets might not have completed elevation data... so you may need to design a "fudging engine" that fills-in the areas where you have no DEM data.

Wow, huh?  phew.  I'm pooped.  You?  :)  Party on!  [fun link]  (mouse-dragging/wheeling active).  Fudging engine!  Artificial intelligence fuzzy-logic body-putty generator... filling-in the cracks.  :)  (Wingnut sprays some Jaggy-B-Gone on the BJS CSG system, just... cuzzzz)

Share this post


Link to post
Share on other sites
On 2017-10-17 at 11:37 AM, BitOfGold said:

There is a cool lib for this:
https://github.com/mgvez/planet-positions

it returns Three.Vector3, but you can .copyFrom that to BABYLON.
 

This is awesome, thanks so much for sharing it!!!

I've just started using it and it's basically done all my work for me :)

I've got the entire solar system working with accurate orbits, and I even used the radius values supplied by `planet-positions.js`

My next step is scaling: I'm experimenting with ways of keeping the relative sizes of the planets accurate but aesthetically scaling the distances between them so that the entire solar system could be viewed as a whole from one camera.

I would love to accurately space the planets, but the problem there is that the solar system is very, very big and very, very empty:

 

Although, I might add a slider to let users set the scale to a realistic 1:1 if they want to. 

Share this post


Link to post
Share on other sites
On 2017-10-21 at 7:50 PM, BitOfGold said:

An alpha version is more or less working now:
https://www.bitofgold.com/solarsystem/

My I ask how you did your planet labels?

(I've very new to using BabylonJS so I'm not sure how this is typically done.)

I've been using simple HTML tags and this bit of code to make them follow the planet positions:

  planetMeshes.forEach((planet, index) => {
    scene.updateTransformMatrix();

    let label = planetLabels[index];
    var position2D = V3.Project(
          planet.position,
          BABYLON.Matrix.Identity(),
          scene.getTransformMatrix(),
          camera.viewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight())
      );

    label.style.left = position2D.x + "px";
    label.style.top = position2D.y + "px";
  });

... the only problem with that is that the labels are on <div> layer above the scene.

So it looks a bit weird when a planet passes behind another because its label still floats on top.

Share this post


Link to post
Share on other sites

First you make a full screen GUI:

 scene.gui = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI");

After that, add a label connected to each planet mesh (planet.model is a BABYLON.Mesh):

var rect1 = new BABYLON.GUI.Rectangle();
rect1.width = "150px";
rect1.height = "40px";
rect1.color = "rgba(255,255,255,0.37)";
rect1.thickness = 0;
rect1.background = "transparent";
scene.gui.addControl(rect1);
var label = new BABYLON.GUI.TextBlock();
label.text = planet.title;
rect1.addControl(label);

rect1.linkWithMesh(planet.model);   
rect1.linkOffsetY = -40;

 

Share this post


Link to post
Share on other sites

If you would travel at the 99% of speed of light, from the spaceship's view it would take only about 6.1 minutes to reach Jupiter. And Jupiter would look as a flat ellipsioid, not a sphere, about 1/14th width of the diameter.
(But, the video would be shorter :D)
 

Share this post


Link to post
Share on other sites

Actually, if you assume that Jupiter is at perihelion at the same time as it is in opposition (with Earth) - making the two worlds closest together - it would take 32.8 mins at 100% the speed of light to travel from Earth to Jupiter. The 6.1 minutes to reach Jupiter is, in my opinion, a little optimistic. Full marks for enthusiasm though ;)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.