Page 1 of 1

Exact Measurements in Celestia

Posted: 09.05.2009, 17:30
by PlutonianEmpire
What are the all of the exact measurements used for Celestia?

Meaning, exactly how many kilometers is one AU, and exactly how many days is one year, and so forth?

I read the answer to those questions somewhere, but I forget where.

Re: Exact Measurements in Celestia

Posted: 09.05.2009, 18:05
by t00fri
PlutonianEmpire wrote:What are the all of the exact measurements used for Celestia?

Meaning, exactly how many kilometers is one AU, and exactly how many days is one year, and so forth?

I read the answer to those questions somewhere, but I forget where.

One amazing implication is that after time run over centuries in Celestia, the planets are still at the right place in the sky...

Fridger

Re: Exact Measurements in Celestia

Posted: 09.05.2009, 19:17
by selden
The values can be found in Celestia's source code on SourceForge.
http://celestia.svn.sourceforge.net/vie ... estia/src/

Most of them are in either astro.h or astro.cpp

Here are a few:
src/celengine/astro.cpp:const double astro::speedOfLight = 299792.458; // km/s
src/celengine/astro.h:#define KM_PER_LY 9460730472580.8
src/celengine/astro.h:#define KM_PER_AU 149597870.7
src/celengine/astro.h:#define LY_PER_PARSEC 3.26167

For a long time Celestia was using this value:
src/celengine/astro.h:// #define OLD_KM_PER_LY 9466411842000.000

The number of days in a Terrestrial year is hardwired in the code in many places: 365.25

Fridger,

When writing Lua orbital and rotation routines, one needs to use exactly the same values as Celestia is using. Too often, they are not the same as what one finds when searching with Google. The number of kilometers in an AU is one example.

Re: Exact Measurements in Celestia

Posted: 09.05.2009, 19:49
by PlutonianEmpire
Thank you! :D

Re: Exact Measurements in Celestia

Posted: 09.05.2009, 22:25
by t00fri
selden wrote:
Fridger,

When writing Lua orbital and rotation routines, one needs to use exactly the same values as Celestia is using. Too often, they are not the same as what one finds when searching with Google. The number of kilometers in an AU is one example.

Selden,

I actually misunderstood the English of that question. Apart from that, it's always bad to take ones information about such things from Google, at least without knowing the author who wrote it...Fortunately, one still cannot write a PhD with Google ;-)

Fridger

Re: Exact Measurements in Celestia

Posted: 25.07.2009, 17:35
by PlutonianEmpire
Sorry for gravedigging, but...

selden wrote:The number of days in a Terrestrial year is hardwired in the code in many places: 365.25
"365.25," is that the exact number that celestia uses, or is it something slightly greater or slightly less? I've looked around, but couldn't find it.

Re: Exact Measurements in Celestia

Posted: 25.07.2009, 18:02
by selden
What do you mean by "looked around"?
In Celestia's source code or somewhere else?

it's in many of Celestia source files.

$ grep 365.25 */*.cpp | more
celengine/astro.cpp: int64 d = (int64) floor((c - 122.1) / 365.25);
celengine/astro.cpp: int64 e = (int64) floor(365.25 * d);
celengine/astro.cpp: return (floor(365.25 * y) +
celengine/customorbit.cpp: return 365.25;
celengine/customorbit.cpp: m2 = jd19/365.2596407;
celengine/customorbit.cpp: double T = t / 365.25;
celengine/customorbit.cpp: double T = t / 365.25;
celengine/customorbit.cpp: double D = d / 365.25; // years
celengine/customorbit.cpp: t2 = t1 / 365.25;
celengine/customorbit.cpp: t3 = (t - 2433282.423) / 365.25 + 1950.0;
celengine/customorbit.cpp: t5 = t4 / 365.25;
celengine/customorbit.cpp: t8 = t6 / 365.25;
celengine/customorbit.cpp: t9 = (t - 2442000.5) / 365.25;
celengine/customorbit.cpp: double T = t / 365.25;
celengine/customorbit.cpp: double theta = degToRad(151.401 + 0.57806 * t
/ 365.25);
celengine/customorbit.cpp: return CreateJPLEphOrbit(JPLEph_Mercury, JPLEp
h_Sun, 0.2408 * 365.25, 6.0e7);
celengine/customorbit.cpp: return CreateJPLEphOrbit(JPLEph_Venus, JPLEp
h_Sun, 0.6152 * 365.25, 1.0e8);
and that's just the first page of grep's output....

Re: Exact Measurements in Celestia

Posted: 25.07.2009, 18:16
by PlutonianEmpire
selden wrote:What do you mean by "looked around"?
In Celestia's source code or somewhere else?

it's in many of Celestia source files.

$ grep 365.25 */*.cpp | more
celengine/astro.cpp: int64 d = (int64) floor((c - 122.1) / 365.25);
celengine/astro.cpp: int64 e = (int64) floor(365.25 * d);
celengine/astro.cpp: return (floor(365.25 * y) +
celengine/customorbit.cpp: return 365.25;
celengine/customorbit.cpp: m2 = jd19/365.2596407;
celengine/customorbit.cpp: double T = t / 365.25;
celengine/customorbit.cpp: double T = t / 365.25;
celengine/customorbit.cpp: double D = d / 365.25; // years
celengine/customorbit.cpp: t2 = t1 / 365.25;
celengine/customorbit.cpp: t3 = (t - 2433282.423) / 365.25 + 1950.0;
celengine/customorbit.cpp: t5 = t4 / 365.25;
celengine/customorbit.cpp: t8 = t6 / 365.25;
celengine/customorbit.cpp: t9 = (t - 2442000.5) / 365.25;
celengine/customorbit.cpp: double T = t / 365.25;
celengine/customorbit.cpp: double theta = degToRad(151.401 + 0.57806 * t
/ 365.25);
celengine/customorbit.cpp: return CreateJPLEphOrbit(JPLEph_Mercury, JPLEp
h_Sun, 0.2408 * 365.25, 6.0e7);
celengine/customorbit.cpp: return CreateJPLEphOrbit(JPLEph_Venus, JPLEp
h_Sun, 0.6152 * 365.25, 1.0e8);
and that's just the first page of grep's output....
I looked around in files in that link you gave me. I was using "year" and "days" as the search term.

My apologies.

Re: Exact Measurements in Celestia

Posted: 25.07.2009, 23:56
by Chuft-Captain
selden wrote:What do you mean by "looked around"?
In Celestia's source code or somewhere else?

it's in many of Celestia source files.
I worry that this literal value is hard-coded in so many places. Best practice would be to declare it once only (for example as days_in_year )and then use that variable/attribute in all these places.

I wonder if a re-factoring of this has ever been attempted?

CC

Re: Exact Measurements in Celestia

Posted: 27.07.2009, 23:53
by Hungry4info
Chuft-Captain wrote:Best practice would be to declare it once only (for example as days_in_year )and then use that variable/attribute in all these places.

That would certainly make the value easier to modify later if the need ever arises.