Orbit constructor

Orbit(
  1. TLE tle
)

Implementation

Orbit(TLE tle) : m_tle = tle {
  m_tle.initialize();

  int epochYear = m_tle.getField(eField.FLD_EPOCHYEAR).round();
  double epochDay = m_tle.getField(eField.FLD_EPOCHDAY);

  if (epochYear < 57)
    epochYear += 2000;
  else
    epochYear += 1900;

  m_jdEpoch = Julian(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, TWOTHRD) as double;
  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 NoradSDP4(this);
  } else {
    // SGP4 - period < 225 minutes
    m_pNoradModel = new NoradSGP4(this);
  }
}