Looking for a library to draw orbits

  • Follow


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
0
Reply Daniel 6/19/2010 11:26:09 AM

On 6/19/2010 7:26 AM, Daniel wrote:
> 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.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid
0
Reply Eric 6/19/2010 12:53:08 PM


Daniel wrote:
>> 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

Why did you put "only" in quotes?

>> 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.

Eric Sosman wrote:
> 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>

-- 
Lew
0
Reply Lew 6/19/2010 1:43:01 PM

On 6/19/2010 9:43 AM, Lew wrote:
> Daniel wrote:
>>> 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
>
> Why did you put "only" in quotes?
>
>>> 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.
>
> Eric Sosman wrote:
>> 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.

     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 ...

-- 
Eric Sosman
esosman@ieee-dot-org.invalid
0
Reply Eric 6/19/2010 2:15:41 PM

On Sat, 19 Jun 2010 21:26:09 +1000, Daniel <noSpam at daik dot se>
wrote, quoted or indirectly quoted someone who said :

>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)
0
Reply Roedy 6/20/2010 2:41:13 AM

On Sat, 19 Jun 2010 10:15:41 -0400, Eric Sosman
<esosman@ieee-dot-org.invalid> wrote:

>On 6/19/2010 9:43 AM, Lew wrote:
>> Daniel wrote:
>>>> 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
>>
>> Why did you put "only" in quotes?
>>
>>>> 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.
>>
>> Eric Sosman wrote:
>>> 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.
>
>     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
0
Reply Daniel 6/20/2010 3:06:16 AM

On Sat, 19 Jun 2010 19:41:13 -0700, Roedy Green
<see_website@mindprod.com.invalid> wrote:

>On Sat, 19 Jun 2010 21:26:09 +1000, Daniel <noSpam at daik dot se>
>wrote, quoted or indirectly quoted someone who said :
>
>>I'm looking for a library to draw the orbits of all planets
>
>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

0
Reply Daniel 6/20/2010 3:08:09 AM

"Daniel" <noSpam at daik dot se> wrote in message 
news:md1r165jvuftopn3om2qg2s7htvgg0rbp3@4ax.com...
> On Sat, 19 Jun 2010 19:41:13 -0700, Roedy Green
> <see_website@mindprod.com.invalid> wrote:
>
>>On Sat, 19 Jun 2010 21:26:09 +1000, Daniel <noSpam at daik dot se>
>>wrote, quoted or indirectly quoted someone who said :
>>
>>>I'm looking for a library to draw the orbits of all planets
>>
>>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
>

In "Just Java 6th Ed", Peter van der Linden mentions an applet named Sky 
View Cafe by Kerry Shetline.  See pages 574 to 578. One of the pictures 
shows the solar system out to Mars.  I believe the code is available and you 
might be able to adapt it to your purpose.

See http://www.skyviewcafe.com/ 


0
Reply Charles 6/20/2010 3:44:02 AM

Daniel wrote:
> 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
<http://en.wikipedia.org/wiki/Pluto#Orbit_and_rotation>
and references therefrom.

> of Eris will be even harder to calculate.

-- 
Lew
0
Reply Lew 6/20/2010 6:15:58 AM

On 6/19/2010 7:26 AM, Daniel wrote:
> 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>

0
Reply Jeff 6/20/2010 10:27:20 AM

On 06/19/2010 07:26 AM, Daniel wrote:
> 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%27s_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.

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth
0
Reply Pidgeot18 (1393) 6/20/2010 6:04:01 PM

On 19/06/2010 11:06 PM, Daniel wrote:
> 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/
0
Reply David 6/20/2010 6:37:16 PM

On 6/20/2010 6:27 AM, Jeff Higgins wrote:
> On 6/19/2010 7:26 AM, Daniel wrote:
>> 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>
>
Thanks for the happy browsing experience.
After several hours I've settled on 'Computus' as my problem for the week.

Have you run across this one?
<http://mhuss.com/AstroLib.html>

0
Reply oohiggins (266) 6/20/2010 11:02:40 PM

On 6/20/2010 7:02 PM, Jeff Higgins wrote:
> On 6/20/2010 6:27 AM, Jeff Higgins wrote:
>> On 6/19/2010 7:26 AM, Daniel wrote:
>>> 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>
>>
> Thanks for the happy browsing experience.
> After several hours I've settled on 'Computus' as my problem for the week.
>
> Have you run across this one?
> <http://mhuss.com/AstroLib.html>
>
Aw, what the heck, I'll put these here for my own future reference.
<http://www.projectpluto.com/>
<http://stjarnhimlen.se/english.html>
<http://nineplanets.org/>
<http://myreckonings.com/wordpress/>
<http://books.google.com/books?id=jYynOwAACAAJ>
<http://books.google.com/books?id=ysZI5NcksUcC>

0
Reply oohiggins (266) 6/21/2010 2:13:33 AM

On Sun, 20 Jun 2010, Jeff Higgins wrote:

> On 6/20/2010 7:02 PM, Jeff Higgins wrote:
>> On 6/20/2010 6:27 AM, Jeff Higgins wrote:
>>> On 6/19/2010 7:26 AM, Daniel wrote:
>>>> 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>
>>> 
>> Thanks for the happy browsing experience.
>> After several hours I've settled on 'Computus' as my problem for the week.
>> 
>> Have you run across this one?
>> <http://mhuss.com/AstroLib.html>
>
> Aw, what the heck, I'll put these here for my own future reference.
> <http://www.projectpluto.com/>
> <http://stjarnhimlen.se/english.html>
> <http://nineplanets.org/>
> <http://myreckonings.com/wordpress/>
> <http://books.google.com/books?id=jYynOwAACAAJ>
> <http://books.google.com/books?id=ysZI5NcksUcC>

Also:

telnet://horizons.jpl.nasa.gov:6775

A solar system catalogue and ephemeris service with a telnet interface!

tom

-- 
I'm angry, but not Milk and Cheese angry. -- Mike Froggatt
0
Reply twic (2083) 6/21/2010 9:36:31 AM

14 Replies
127 Views

(page loaded in 0.139 seconds)

Similiar Articles:























6/23/2012 4:42:33 AM


Reply: