From: Joshua Cranmer on
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
From: David Lamb on
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/
From: Jeff Higgins on
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>

From: Jeff Higgins on
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>

From: Tom Anderson on
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