Units in catalogue files
Posted: 28.11.2009, 17:58
The attached file contains a diff against the src directory in SVN revision 4915 adds the ability to specify units for the Period and SemiMajorAxis properties in the EllipticalOrbit part of Celestia's input files. It also contains a test .ssc file to demonstrate this functionality.
The syntax is to place the unit in angle brackets after the property name, e.g.
Which will place a planet in a 1 year orbit at a distance of 1 AU from Alpha Mensae. The units list in angle brackets is treated as a space-separated list, since some of the properties that can be specified in .ssc files allow more than one type of unit (e.g. LongLat which combines angular and length units) - none of these properties have these units specified yet but this is planned for the future. Only one unit per type can be specified, e.g. if you specify SemiMajorAxis<km AU> then km will be used. Units are case-sensitive.
Units currently supported are:
Length units: m, km, AU, ly
Time units: s, h, d, y
In terms of the internals of how it works, the <units> construction gets parsed to properties such as SemiMajorAxis%Length, Period%Time depending on the unit (a limitation of this approach is that it is not possible to have two units of different types with the same name). These properties cannot be specified directly in the catalogue file because of the % sign.
I plan to add more units in due course, my current plan is for the following:
Length units: m, km, rE (=Earth radius), rJ (=Jupiter radius), rS (=Solar radius), AU, ly, pc, kpc, Mpc
Time units: s, min, h, d, y
Angle units: mas (=milliarcsecond), arcsec (=arcsecond), deg, hRA (=hour of right ascension), rad
Mass units: kg, mE (=Earth mass), mJ (=Jupiter mass), mS (=Solar mass)
(No guarantees that this won't explode your computer or something... I have a lot more experience with C# than I do with C++, which is a far less forgiving language and I may have managed to do something spectacularly idiotic here. On the other hand, it seems to work for me running the qt4 version on Linux)
Edit: removed old version of patch
The syntax is to place the unit in angle brackets after the property name, e.g.
Code: Select all
"TestUnits1" "Alf Men"
{
Radius 70000
Texture "exo-class3.*"
EllipticalOrbit {
Period<d> 365.25
SemiMajorAxis<km> 149597870.7
MeanAnomaly 30
}
}
Which will place a planet in a 1 year orbit at a distance of 1 AU from Alpha Mensae. The units list in angle brackets is treated as a space-separated list, since some of the properties that can be specified in .ssc files allow more than one type of unit (e.g. LongLat which combines angular and length units) - none of these properties have these units specified yet but this is planned for the future. Only one unit per type can be specified, e.g. if you specify SemiMajorAxis<km AU> then km will be used. Units are case-sensitive.
Units currently supported are:
Length units: m, km, AU, ly
Time units: s, h, d, y
In terms of the internals of how it works, the <units> construction gets parsed to properties such as SemiMajorAxis%Length, Period%Time depending on the unit (a limitation of this approach is that it is not possible to have two units of different types with the same name). These properties cannot be specified directly in the catalogue file because of the % sign.
I plan to add more units in due course, my current plan is for the following:
Length units: m, km, rE (=Earth radius), rJ (=Jupiter radius), rS (=Solar radius), AU, ly, pc, kpc, Mpc
Time units: s, min, h, d, y
Angle units: mas (=milliarcsecond), arcsec (=arcsecond), deg, hRA (=hour of right ascension), rad
Mass units: kg, mE (=Earth mass), mJ (=Jupiter mass), mS (=Solar mass)
(No guarantees that this won't explode your computer or something... I have a lot more experience with C# than I do with C++, which is a far less forgiving language and I may have managed to do something spectacularly idiotic here. On the other hand, it seems to work for me running the qt4 version on Linux)
Edit: removed old version of patch