I've asked a few questions to do with this in the last day or so and received answers that have led to more questions...
How to use David Vallado's AstroLib to do reference frame conversions
https://space.stackexchange.com/a/61482/18594
In essense, I need to convert Keplerian Orbital Definitions in this form:
[
{
"CCSDS_OMM_VERS": "2.0",
"COMMENT": "GENERATED VIA SPACE-TRACK.ORG API",
"CREATION_DATE": "2022-12-22T18:47:50",
"ORIGINATOR": "18 SPCS",
"OBJECT_NAME": "TBA - TO BE ASSIGNED",
"OBJECT_ID": "",
"CENTER_NAME": "EARTH",
"REF_FRAME": "TEME",
"TIME_SYSTEM": "UTC",
"MEAN_ELEMENT_THEORY": "SGP4",
"EPOCH": "2022-12-22T09:47:18.097440",
"MEAN_MOTION": "12.95271318",
"ECCENTRICITY": "0.00298554",
"INCLINATION": "90.2548",
"RA_OF_ASC_NODE": "337.7299",
"ARG_OF_PERICENTER": "225.6432",
"MEAN_ANOMALY": "134.2241",
"EPHEMERIS_TYPE": "0",
"CLASSIFICATION_TYPE": "U",
"NORAD_CAT_ID": "270288",
"ELEMENT_SET_NO": "999",
"REV_AT_EPOCH": "12946",
"BSTAR": "0.00171121940000",
"MEAN_MOTION_DOT": "0.00000489",
"MEAN_MOTION_DDOT": "0.0000000000000",
"SEMIMAJOR_AXIS": "7658.811",
"PERIOD": "111.174",
"APOAPSIS": "1303.541",
"PERIAPSIS": "1257.810",
"OBJECT_TYPE": "UNKNOWN",
"RCS_SIZE": null,
"COUNTRY_CODE": null,
"LAUNCH_DATE": null,
"SITE": null,
"DECAY_DATE": null,
"FILE": "3719197",
"GP_ID": "221188557",
"TLE_LINE0": "0 TBA - TO BE ASSIGNED",
"TLE_LINE1": "1 T0288U 22356.40784835 .00000489 00000-0 17112-2 0 9990",
"TLE_LINE2": "2 T0288 90.2548 337.7299 0029855 225.6432 134.2241 12.95271318129469"
}
]
Between TEME and J2000. (Later on, I might add other reference frames)
The prevailing wisdom seems to be to use David Vallado's Astrolib. Unfortunately, that lib seems quite poorly documented and the code is written from the perspective of an astrodynamicist, not a software engineer, so it's not exactly the most legible. I'm sure if I had his textbook, it would explain things further, but I don't have a spare £200 and a week to wait.
So, piecing together bits and bobs from various different sources, I've come up with this:
public static Orbit ConvertTEMEToJ2000(Orbit orbit)
{
// Convert the TEME orbital elements to J2000 orbital elements
double a = orbit.SemiMajorAxis;
double e = orbit.Eccentricity;
double i = orbit.Inclination;
double argOfPeriapsis = orbit.ArgumentOfPeriapsis;
double raan = orbit.RightAscensionOfAscendingNode;
double m = orbit.MeanAnomaly;
double t = (double)(DateTime.NowUtc.Year - 2000)/100;
// Calculate precession angles
double zeta = (2306.2181 + 1.39656 * t - 0.000139 * t * t) * 0.00001 * Math.Pi / 180;
double z = (2306.2181 + 1.39656 * t - 0.000139 * t * t) * 0.00001 * Math.Pi / 180;
double theta = (2004.3109 - 0.85330 * t - 0.000217 * t * t) * 0.00001 * Math.PI / 180;
// Calculate the new longitude of the ascending node
double newRaan = raan - zeta - theta;
// Calculate the new argument of periapsis
double newArgPeriapsis = argOfPeriapsis - z - theta;
// Create a new orbit object in the J2000 reference frame
Orbit j2000Orbit = new Orbit(a, e, i, omega2, omega1, m);
return j2000Orbit;
}
This seems far simpler than what's in the library I mentioned, so I'm all but certain I'm missing something.
My question boils down to:
- Is my above attempt correct?
- If not, what algorithm is used for the conversion (I have a bounty on this question asking for the same as all other answers to that question just refer to libs).