IodLaplace.java

  1. /* Copyright 2002-2020 CS GROUP
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.estimation.iod;

  18. import org.hipparchus.analysis.solvers.LaguerreSolver;
  19. import org.hipparchus.complex.Complex;
  20. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  21. import org.hipparchus.linear.Array2DRowRealMatrix;
  22. import org.hipparchus.linear.LUDecomposition;
  23. import org.hipparchus.util.FastMath;
  24. import org.orekit.frames.Frame;
  25. import org.orekit.orbits.CartesianOrbit;
  26. import org.orekit.time.AbsoluteDate;
  27. import org.orekit.utils.PVCoordinates;

  28. /**
  29.  * Laplace angles-only initial orbit determination, assuming Keplerian motion.
  30.  * An orbit is determined from three angular observations from the same site.
  31.  *
  32.  *
  33.  * Reference:
  34.  *    Bate, R., Mueller, D. D., & White, J. E. (1971). Fundamentals of astrodynamics.
  35.  *    New York: Dover Publications.
  36.  *
  37.  * @author Shiva Iyer
  38.  * @since 10.1
  39.  */
  40. public class IodLaplace {

  41.     /** Gravitational constant. */
  42.     private final double mu;

  43.     /** Constructor.
  44.      *
  45.      * @param mu  gravitational constant
  46.      */
  47.     public IodLaplace(final double mu) {
  48.         this.mu = mu;
  49.     }

  50.     /** Estimate orbit from three line of sight angles from the same location.
  51.      *
  52.      * @param frame inertial frame for observer coordinates and orbit estimate
  53.      * @param obsPva Observer coordinates at time obsDate2
  54.      * @param obsDate1 date of observation 1
  55.      * @param los1 line of sight unit vector 1
  56.      * @param obsDate2 date of observation 2
  57.      * @param los2 line of sight unit vector 2
  58.      * @param obsDate3 date of observation 3
  59.      * @param los3 line of sight unit vector 3
  60.      * @return estimate of the orbit at the central date dateObs2 or null if
  61.      *         no estimate is possible with the given data
  62.      */
  63.     public CartesianOrbit estimate(final Frame frame, final PVCoordinates obsPva,
  64.                                    final AbsoluteDate obsDate1, final Vector3D los1,
  65.                                    final AbsoluteDate obsDate2, final Vector3D los2,
  66.                                    final AbsoluteDate obsDate3, final Vector3D los3) {
  67.         // The first observation is taken as t1 = 0
  68.         final double t2 = obsDate2.durationFrom(obsDate1);
  69.         final double t3 = obsDate3.durationFrom(obsDate1);

  70.         // Calculate the first and second derivatives of the Line Of Sight vector at t2
  71.         final Vector3D Ldot = los1.scalarMultiply((t2 - t3) / (t2 * t3)).
  72.                         add(los2.scalarMultiply((2.0 * t2 - t3) / (t2 * (t2 - t3)))).
  73.                         add(los3.scalarMultiply(t2 / (t3 * (t3 - t2))));
  74.         final Vector3D Ldotdot = los1.scalarMultiply(2.0 / (t2 * t3)).
  75.                         add(los2.scalarMultiply(2.0 / (t2 * (t2 - t3)))).
  76.                         add(los3.scalarMultiply(2.0 / (t3 * (t3 - t2))));

  77.         // The determinant will vanish if the observer lies in the plane of the orbit at t2
  78.         final double D = 2.0 * getDeterminant(los2, Ldot, Ldotdot);
  79.         if (FastMath.abs(D) < 1.0E-14) {
  80.             return null;
  81.         }

  82.         final double Dsq = D * D;
  83.         final double R = obsPva.getPosition().getNorm();
  84.         final double RdotL = obsPva.getPosition().dotProduct(los2);

  85.         final double D1 = getDeterminant(los2, Ldot, obsPva.getAcceleration());
  86.         final double D2 = getDeterminant(los2, Ldot, obsPva.getPosition());

  87.         // Coefficients of the 8th order polynomial we need to solve to determine "r"
  88.         final double[] coeff = new double[] {-4.0 * mu * mu * D2 * D2 / Dsq,
  89.                                              0.0,
  90.                                              0.0,
  91.                                              4.0 * mu * D2 * (RdotL / D - 2.0 * D1 / Dsq),
  92.                                              0.0,
  93.                                              0.0,
  94.                                              4.0 * D1 * RdotL / D - 4.0 * D1 * D1 / Dsq - R * R, 0.0,
  95.                                              1.0};

  96.         // Use the Laguerre polynomial solver and take the initial guess to be
  97.         // 5 times the observer's position magnitude
  98.         final LaguerreSolver solver = new LaguerreSolver(1E-10, 1E-10, 1E-10);
  99.         final Complex[] roots = solver.solveAllComplex(coeff, 5.0 * R);

  100.         // We consider "r" to be the positive real root with the largest magnitude
  101.         double rMag = 0.0;
  102.         for (int i = 0; i < roots.length; i++) {
  103.             if (roots[i].getReal() > rMag &&
  104.                             FastMath.abs(roots[i].getImaginary()) < solver.getAbsoluteAccuracy()) {
  105.                 rMag = roots[i].getReal();
  106.             }
  107.         }
  108.         if (rMag == 0.0) {
  109.             return null;
  110.         }

  111.         // Calculate rho, the slant range from the observer to the satellite at t2.
  112.         // This yields the "r" vector, which is the satellite's position vector at t2.
  113.         final double rCubed = rMag * rMag * rMag;
  114.         final double rho = -2.0 * D1 / D - 2.0 * mu * D2 / (D * rCubed);
  115.         final Vector3D posVec = los2.scalarMultiply(rho).add(obsPva.getPosition());

  116.         // Calculate rho_dot at t2, which will yield the satellite's velocity vector at t2
  117.         final double D3 = getDeterminant(los2, obsPva.getAcceleration(), Ldotdot);
  118.         final double D4 = getDeterminant(los2, obsPva.getPosition(), Ldotdot);
  119.         final double rhoDot = -D3 / D - mu * D4 / (D * rCubed);
  120.         final Vector3D velVec = los2.scalarMultiply(rhoDot).
  121.                         add(Ldot.scalarMultiply(rho)).
  122.                         add(obsPva.getVelocity());

  123.         // Return the estimated orbit
  124.         return new CartesianOrbit(new PVCoordinates(posVec, velVec), frame, obsDate2, mu);
  125.     }

  126.     /** Calculate the determinant of the matrix with given column vectors.
  127.      *
  128.      * @param col0 Matrix column 0
  129.      * @param col1 Matrix column 1
  130.      * @param col2 Matrix column 2
  131.      * @return matrix determinant
  132.      *
  133.      */
  134.     private double getDeterminant(final Vector3D col0, final Vector3D col1, final Vector3D col2) {
  135.         final Array2DRowRealMatrix mat = new Array2DRowRealMatrix(3, 3);
  136.         mat.setColumn(0, col0.toArray());
  137.         mat.setColumn(1, col1.toArray());
  138.         mat.setColumn(2, col2.toArray());
  139.         return new LUDecomposition(mat).getDeterminant();
  140.     }
  141. }