Looking for a library to draw orbits

D

Daniel

Hello all,
I'm looking for a library to draw the orbits of all planets, dwarf
planets and moons in the solar system. I'm looking for this for a game
project, so it does not need to be 100% accurate but it needs to be
close. Even if the library can "only" draw the planets I am
interested. Does anyone know of any good libraries to do this? This is
for an open source project so the license needs to be compatible with
open source projects.

regards
Daniel
 
E

Eric Sosman

Hello all,
I'm looking for a library to draw the orbits of all planets, dwarf
planets and moons in the solar system. I'm looking for this for a game
project, so it does not need to be 100% accurate but it needs to be
close. Even if the library can "only" draw the planets I am
interested. Does anyone know of any good libraries to do this? This is
for an open source project so the license needs to be compatible with
open source projects.

Just draw ellipses. The difference between an ellipse and the
planet's true lumpy-bumpy path will be too small to see at the coarse
resolution of a computer screen.

For that matter, most moons will be indistinguishable from the
planets they circle. Let's see: Neptune's mean distance from the Sun
is 2.8 billion miles, so a display of the full orbit must span a
scaled distance of 5.6 billion miles. If the screen is 2000 pixels
across, each pixel represents somewhat more than 2.8 million miles.
Neptune's most distant known moon, Neso, is about 30 million miles
from the planet, not quite eleven pixels. The innermost seven moons
are all less than one-eighth of a pixel away, so they'll display
right on top of Neptune itself.
 
L

Lew

Why did you put "only" in quotes?

Eric said:
Just draw ellipses. The difference between an ellipse and the
planet's true lumpy-bumpy path will be too small to see at the coarse
resolution of a computer screen.

For that matter, most moons will be indistinguishable from the
planets they circle. Let's see: Neptune's mean distance from the Sun
is 2.8 billion miles, so a display of the full orbit must span a
scaled distance of 5.6 billion miles. If the screen is 2000 pixels
across, each pixel represents somewhat more than 2.8 million miles.
Neptune's most distant known moon, Neso, is about 30 million miles
from the planet, not quite eleven pixels. The innermost seven moons
are all less than one-eighth of a pixel away, so they'll display
right on top of Neptune itself.

At the scale that shows Neptune, Mercury's orbit on your hypothetical screen
similarly would vary from, oh, ten to nineteen pixels from the Sun. Half that
if you want to show the Kuiper belt.

Googling found me this:
http://csep10.phys.utk.edu/astr161/lect/solarsys/planet_orbits.gif

You did Google for this, right? I got a ton of likely-looking hits from
<http://www.google.com/search?q=planetary+orbits+Java+draw+open+source>
 
E

Eric Sosman

Why did you put "only" in quotes?




At the scale that shows Neptune, Mercury's orbit on your hypothetical
screen similarly would vary from, oh, ten to nineteen pixels from the
Sun. Half that if you want to show the Kuiper belt.

And Luna would be about one-tenth of a pixel from Terra, which
may be all right because Terra itself is only 0.003 pixels across.
And you don't even want to think about Phobos ...

The point of all this scale-mongering is to get the O.P. to
think about what he's trying to do. A true-scale view of the
Solar system on a screen whose resolution can't be finer than 0.05%
is just not going to show the sort of detail he mentions, and is not
going to look very good in his game. He's going to have to change
his, er, viewpoint in some way to get anywhere. Two possibilities:

- Don't try to show the entire Solar system all at once, but
zoom in on the region where Captain Zoom is battling the
Underlings of the Overlord. Focus on Neptune itself and let
the Sun drift far off-screen, and you'll be able to scale up
to the point where things start to become visible.

- Cheat. Show the entire Solar system, but selectively magnify
some distances and shrink others to make a pretty picture.
Make Terra the size of six Jupiters, drag Neptune in to about
Mars' orbit, let the space ships travel at a hundred c or so,
that sort of thing.

.... and surely there are other approaches a game writer might employ.

Google found <http://www.phrenopolis.com/perspective/solarsystem/>
for me, a page that displays a to-scale rendering of the Solar system
with the Sun shrunken from its normal 800,000 miles down to about six
inches. As the page's text points out, "That makes this page rather
large - on an ordinary 72 dpi monitor it's just over half a mile wide."
Use a steady hand on the scroll bar ...
 
R

Roedy Green

I'm looking for a library to draw the orbits of all planets

Would not just a simple ellipse do?

java.awt.geom
--
Roedy Green Canadian Mind Products
http://mindprod.com

There is no harm in being sometimes wrong especially if one is promptly found out.
~ John Maynard Keynes (born: 1883-06-05 died: 1946-04-21 at age: 62)
 
D

Daniel

And Luna would be about one-tenth of a pixel from Terra, which
may be all right because Terra itself is only 0.003 pixels across.
And you don't even want to think about Phobos ...

The point of all this scale-mongering is to get the O.P. to
think about what he's trying to do. A true-scale view of the
Solar system on a screen whose resolution can't be finer than 0.05%
is just not going to show the sort of detail he mentions, and is not
going to look very good in his game. He's going to have to change
his, er, viewpoint in some way to get anywhere. Two possibilities:

- Don't try to show the entire Solar system all at once, but
zoom in on the region where Captain Zoom is battling the
Underlings of the Overlord. Focus on Neptune itself and let
the Sun drift far off-screen, and you'll be able to scale up
to the point where things start to become visible.

- Cheat. Show the entire Solar system, but selectively magnify
some distances and shrink others to make a pretty picture.
Make Terra the size of six Jupiters, drag Neptune in to about
Mars' orbit, let the space ships travel at a hundred c or so,
that sort of thing.

... and surely there are other approaches a game writer might employ.

Google found <http://www.phrenopolis.com/perspective/solarsystem/>
for me, a page that displays a to-scale rendering of the Solar system
with the Sun shrunken from its normal 800,000 miles down to about six
inches. As the page's text points out, "That makes this page rather
large - on an ordinary 72 dpi monitor it's just over half a mile wide."
Use a steady hand on the scroll bar ...

Since we went down this path let me clarify what I am actually trying
to do.
There are three basic views in my game

1. Inner system, Sun-asteroid belt
2. Outer system sun asteroid belt-Eris
3. Planetary view (for example Earth-Moon, or Mars-Phobos-Deimos)

I am very well aware of scale, my post was to try to find a library to
help me do the actual position of the bodies at a given date and time.
Hopefully I can use the same library to draw the moon locations when
in the planetary view.

I am happy to draw the orbits as ellipsis however, determining where
on the ellipse a planet is at a given date is a bit more tricky. From
my research I'm lead to believe that we currently have no numerical
way of determining Plutos orbit, which makes me believe that the orbit
of Eris will be even harder to calculate. Apart from that doing all
the calculations of where the major planets are is not trivial, and
again if there is a library to help me do this it is much less bug
prone than me rolling my own. So again, does anyone know if such a
library exits?

-daniel
 
D

Daniel

Would not just a simple ellipse do?

java.awt.geom

The ellipse is fine as a shape, but I also need to know the location
of the planet along that ellipse, and that is where the problem
starts. I suppose I was not entirely clear, I do not only want to draw
the orbits but also the planets along the orbit.

-daniel
 
L

Lew

Daniel said:
I am happy to draw the orbits as ellips[e]s however, determining where
on the ellipse a planet is at a given date is a bit more tricky. From
my research I'm lead to believe that we currently have no numerical
way of determining Plutos orbit, which makes me believe that the orbit

One can calculate it for the next 10-20 million years, though, according to
 
J

Jeff Higgins

Hello all,
I'm looking for a library to draw the orbits of all planets, dwarf
planets and moons in the solar system. I'm looking for this for a game
project, so it does not need to be 100% accurate but it needs to be
close. Even if the library can "only" draw the planets I am
interested. Does anyone know of any good libraries to do this? This is
for an open source project so the license needs to be compatible with
open source projects.

regards
Daniel
This may not answer your quest for a Java library but I found the links
on this page interesting.
<http://nineplanets.org/data.html>
 
J

Joshua Cranmer

Hello all,
I'm looking for a library to draw the orbits of all planets, dwarf
planets and moons in the solar system. I'm looking for this for a game
project, so it does not need to be 100% accurate but it needs to be
close. Even if the library can "only" draw the planets I am
interested. Does anyone know of any good libraries to do this? This is
for an open source project so the license needs to be compatible with
open source projects.

According to
<http://en.wikipedia.org/wiki/Kepler's_Laws#Position_as_a_function_of_time>,
given the eccentricity of a planet's orbit and its orbital period, you
can compute its polar coordinate for any given time t.

You can do it roughly as follows:

class PolarCoordinate { double r; double theta; }

public PolarCoordinate positionAtTime(double time, double period, double
eccentricity, double perihelion) {
/* Theoretically, you can calculate the perihelion from the
orbital period (and Kepler's third law). Since this figure is
so often listed in tables anyways, I'll just assume you have this
value already at hand. */
double meanAnomaly = 2*Math.pi*time / period;
/* Use a math solving library to solve M = E - epsilon * sin E */
/* Or roll your own using, e.g., Newton's method. */
double eccentricAnomaly = solve(meanAnomaly, eccentricity);
double theta = 2 * Math.atan(
Math.sqrt(1 + eccentricity) * Math.tan(eccentricAnomaly) /
Math.sqrt(1 - eccentricity)
);
double r = perihelion * (1 + eccentricity) /
(1 + eccentricity * Math.sqrt(theta));
return new PolarCoordinate(r, theta);
}

Disclaimer: the comment in my signature applies to the above code.

About your open-source license comment: are you licensing as GPL, BSD,
LGPL, Apache... ? The license you are using for your project does impact
what licenses you can allow.
 
D

David Lamb

I am very well aware of scale, my post was to try to find a library to
help me do the actual position of the bodies at a given date and time.
Hopefully I can use the same library to draw the moon locations when
in the planetary view.

Such a simulator is sometimes called an orrery; I found references to
many on Google, the first of which was http://www.cuug.ab.ca/kmcclary/
 
J

Jeff Higgins

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top