cOrbit::cOrbit(const cTle &tle) : m_tle(tle), m_pNoradModel(NULL) { InitializeCachingVars(); int epochYear = (int)m_tle.GetField(cTle::FLD_EPOCHYEAR); double epochDay = m_tle.GetField(cTle::FLD_EPOCHDAY ); if (epochYear < 57) { epochYear += 2000; } else { epochYear += 1900; } m_jdEpoch = cJulian(epochYear, epochDay); m_secPeriod = -1.0; // Recover the original mean motion and semimajor axis from the // input elements. double mm = MeanMotionTle(); double rpmin = mm * TWOPI / MIN_PER_DAY; // rads per minute double a1 = pow(XKE / rpmin, 2.0 / 3.0); double e = Eccentricity(); double i = Inclination(); double temp = (1.5 * CK2 * (3.0 * sqr(cos(i)) - 1.0) / pow(1.0 - e * e, 1.5)); double delta1 = temp / (a1 * a1); double a0 = a1 * (1.0 - delta1 * ((1.0 / 3.0) + delta1 * (1.0 + 134.0 / 81.0 * delta1))); double delta0 = temp / (a0 * a0); m_rmMeanMotionRec = rpmin / (1.0 + delta0); m_aeAxisSemiMajorRec = a0 / (1.0 - delta0); m_aeAxisSemiMinorRec = m_aeAxisSemiMajorRec * sqrt(1.0 - (e * e)); m_kmPerigeeRec = XKMPER_WGS72 * (m_aeAxisSemiMajorRec * (1.0 - e) - AE); m_kmApogeeRec = XKMPER_WGS72 * (m_aeAxisSemiMajorRec * (1.0 + e) - AE); if (TWOPI / m_rmMeanMotionRec >= 225.0) { // SDP4 - period >= 225 minutes. m_pNoradModel = new cNoradSDP4(*this); } else { // SGP4 - period < 225 minutes m_pNoradModel = new cNoradSGP4(*this); } }
Quaterniond cOrbit::RotationToReferenceFrame() const { Vector3d axisOfInclination(std::cos(-ArgumentOfPeriapsis()), std::sin(-ArgumentOfPeriapsis()), 0); // not tested at nonzero inclinations return AngleAxisd(- LongitudeOfAscendingNode() - ArgumentOfPeriapsis(), Vector3d::UnitZ()) * AngleAxisd(- Inclination(), axisOfInclination); }
OrbitalElements::OrbitalElements(const Tle& tle) { /* * extract and format tle data */ mean_anomoly_ = tle.MeanAnomaly(false); ascending_node_ = tle.RightAscendingNode(false); argument_perigee_ = tle.ArgumentPerigee(false); eccentricity_ = tle.Eccentricity(); inclination_ = tle.Inclination(false); mean_motion_ = tle.MeanMotion() * kTWOPI / kMINUTES_PER_DAY; bstar_ = tle.BStar(); epoch_ = tle.Epoch(); /* * recover original mean motion (xnodp) and semimajor axis (aodp) * from input elements */ const double a1 = pow(kXKE / MeanMotion(), kTWOTHIRD); const double cosio = cos(Inclination()); const double theta2 = cosio * cosio; const double x3thm1 = 3.0 * theta2 - 1.0; const double eosq = Eccentricity() * Eccentricity(); const double betao2 = 1.0 - eosq; const double betao = sqrt(betao2); const double temp = (1.5 * kCK2) * x3thm1 / (betao * betao2); const double del1 = temp / (a1 * a1); const double a0 = a1 * (1.0 - del1 * (1.0 / 3.0 + del1 * (1.0 + del1 * 134.0 / 81.0))); const double del0 = temp / (a0 * a0); recovered_mean_motion_ = MeanMotion() / (1.0 + del0); /* * alternative way to calculate * doesnt affect final results * recovered_semi_major_axis_ = pow(XKE / RecoveredMeanMotion(), TWOTHIRD); */ recovered_semi_major_axis_ = a0 / (1.0 - del0); /* * find perigee and period */ perigee_ = (RecoveredSemiMajorAxis() * (1.0 - Eccentricity()) - kAE) * kXKMPER; period_ = kTWOPI / RecoveredMeanMotion(); }