Example #1
0
    /**
     * Compute mean state from osculating state.
     *
     * <p>Compute in a DSST sense the mean state corresponding to the input osculating state.
     *
     * <p>The computing is done through a fixed-point iteration process.
     *
     * @param osculating initial osculating state
     * @return mean state
     * @throws OrekitException if the underlying computation of short periodic variation fails
     */
    private Orbit computeMeanOrbit(final SpacecraftState osculating) throws OrekitException {

      // rough initialization of the mean parameters
      EquinoctialOrbit meanOrbit = new EquinoctialOrbit(osculating.getOrbit());

      // threshold for each parameter
      final double epsilon = 1.0e-13;
      final double thresholdA = epsilon * (1 + FastMath.abs(meanOrbit.getA()));
      final double thresholdE = epsilon * (1 + meanOrbit.getE());
      final double thresholdAngles = epsilon * FastMath.PI;

      int i = 0;
      while (i++ < 200) {

        final SpacecraftState meanState =
            new SpacecraftState(meanOrbit, osculating.getAttitude(), osculating.getMass());
        // recompute the osculating parameters from the current mean parameters
        final EquinoctialOrbit rebuilt = (EquinoctialOrbit) computeOsculatingOrbit(meanState);

        // adapted parameters residuals
        final double deltaA = osculating.getA() - rebuilt.getA();
        final double deltaEx = osculating.getEquinoctialEx() - rebuilt.getEquinoctialEx();
        final double deltaEy = osculating.getEquinoctialEy() - rebuilt.getEquinoctialEy();
        final double deltaHx = osculating.getHx() - rebuilt.getHx();
        final double deltaHy = osculating.getHy() - rebuilt.getHy();
        final double deltaLm = MathUtils.normalizeAngle(osculating.getLM() - rebuilt.getLM(), 0.0);

        // check convergence
        if ((FastMath.abs(deltaA) < thresholdA)
            && (FastMath.abs(deltaEx) < thresholdE)
            && (FastMath.abs(deltaEy) < thresholdE)
            && (FastMath.abs(deltaLm) < thresholdAngles)) {
          return meanOrbit;
        }

        // update mean parameters
        meanOrbit =
            new EquinoctialOrbit(
                meanOrbit.getA() + deltaA,
                meanOrbit.getEquinoctialEx() + deltaEx,
                meanOrbit.getEquinoctialEy() + deltaEy,
                meanOrbit.getHx() + deltaHx,
                meanOrbit.getHy() + deltaHy,
                meanOrbit.getLM() + deltaLm,
                PositionAngle.MEAN,
                meanOrbit.getFrame(),
                meanOrbit.getDate(),
                meanOrbit.getMu());
      }

      throw new PropagationException(OrekitMessages.UNABLE_TO_COMPUTE_DSST_MEAN_PARAMETERS, i);
    }
  private void checkCartesianToEllipsoidic(
      double ae,
      double f,
      double x,
      double y,
      double z,
      double longitude,
      double latitude,
      double altitude)
      throws OrekitException {

    AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    OneAxisEllipsoid model = new OneAxisEllipsoid(ae, f, frame);
    GeodeticPoint gp = model.transform(new Vector3D(x, y, z), frame, date);
    Assert.assertEquals(longitude, MathUtils.normalizeAngle(gp.getLongitude(), longitude), 1.0e-10);
    Assert.assertEquals(latitude, gp.getLatitude(), 1.0e-10);
    Assert.assertEquals(altitude, gp.getAltitude(), 1.0e-10 * FastMath.abs(ae));
    Vector3D rebuiltNadir = Vector3D.crossProduct(gp.getSouth(), gp.getWest());
    Assert.assertEquals(0, rebuiltNadir.subtract(gp.getNadir()).getNorm(), 1.0e-15);
  }