FieldAuxiliaryElements.java

  1. /* Copyright 2002-2022 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.propagation.semianalytical.dsst.utilities;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  20. import org.hipparchus.util.FastMath;
  21. import org.hipparchus.util.MathUtils;
  22. import org.orekit.frames.Frame;
  23. import org.orekit.orbits.FieldOrbit;
  24. import org.orekit.time.FieldAbsoluteDate;

  25. /** Container class for common parameters used by all DSST forces.
  26.  *  <p>
  27.  *  Most of them are defined in Danielson paper at § 2.1.
  28.  *  </p>
  29.  */
  30. public class FieldAuxiliaryElements<T extends CalculusFieldElement<T>> {

  31.     /** Orbit date. */
  32.     private final FieldAbsoluteDate<T> date;

  33.     /** Orbit frame. */
  34.     private final Frame frame;

  35.     /** Eccentricity. */
  36.     private final T ecc;

  37.     /** Keplerian mean motion. */
  38.     private final T n;

  39.     /** Keplerian period. */
  40.     private final T period;

  41.     /** Semi-major axis. */
  42.     private final T sma;

  43.     /** x component of eccentricity vector. */
  44.     private final T k;

  45.     /** y component of eccentricity vector. */
  46.     private final T h;

  47.     /** x component of inclination vector. */
  48.     private final T q;

  49.     /** y component of inclination vector. */
  50.     private final T p;

  51.     /** Mean longitude. */
  52.     private final T lm;

  53.     /** True longitude. */
  54.     private final T lv;

  55.     /** Eccentric longitude. */
  56.     private final T le;

  57.     /** Retrograde factor I.
  58.      *  <p>
  59.      *  DSST model needs equinoctial orbit as internal representation.
  60.      *  Classical equinoctial elements have discontinuities when inclination
  61.      *  is close to zero. In this representation, I = +1. <br>
  62.      *  To avoid this discontinuity, another representation exists and equinoctial
  63.      *  elements can be expressed in a different way, called "retrograde" orbit.
  64.      *  This implies I = -1. <br>
  65.      *  As Orekit doesn't implement the retrograde orbit, I is always set to +1.
  66.      *  But for the sake of consistency with the theory, the retrograde factor
  67.      *  has been kept in the formulas.
  68.      *  </p>
  69.      */
  70.     private final int    I;

  71.     /** B = sqrt(1 - h² - k²). */
  72.     private final T B;

  73.     /** C = 1 + p² + q². */
  74.     private final T C;

  75.     /** Equinoctial frame f vector. */
  76.     private final FieldVector3D<T> f;

  77.     /** Equinoctial frame g vector. */
  78.     private final FieldVector3D<T> g;

  79.     /** Equinoctial frame w vector. */
  80.     private final FieldVector3D<T> w;

  81.     /** Direction cosine α. */
  82.     private final T alpha;

  83.     /** Direction cosine β. */
  84.     private final T beta;

  85.     /** Direction cosine γ. */
  86.     private final T gamma;

  87.     /** Simple constructor.
  88.      * @param orbit related mean orbit for auxiliary elements
  89.      * @param retrogradeFactor retrograde factor I [Eq. 2.1.2-(2)]
  90.      */
  91.     public FieldAuxiliaryElements(final FieldOrbit<T> orbit, final int retrogradeFactor) {

  92.         final T pi = orbit.getDate().getField().getZero().getPi();

  93.         // Date of the orbit
  94.         date = orbit.getDate();

  95.         // Orbit definition frame
  96.         frame = orbit.getFrame();

  97.         // Eccentricity
  98.         ecc = orbit.getE();

  99.         // Keplerian mean motion
  100.         n = orbit.getKeplerianMeanMotion();

  101.         // Keplerian period
  102.         period = orbit.getKeplerianPeriod();

  103.         // Equinoctial elements [Eq. 2.1.2-(1)]
  104.         sma = orbit.getA();
  105.         k   = orbit.getEquinoctialEx();
  106.         h   = orbit.getEquinoctialEy();
  107.         q   = orbit.getHx();
  108.         p   = orbit.getHy();
  109.         lm  = MathUtils.normalizeAngle(orbit.getLM(), pi);
  110.         lv  = MathUtils.normalizeAngle(orbit.getLv(), pi);
  111.         le  = MathUtils.normalizeAngle(orbit.getLE(), pi);

  112.         // Retrograde factor [Eq. 2.1.2-(2)]
  113.         I = retrogradeFactor;

  114.         final T k2 = k.multiply(k);
  115.         final T h2 = h.multiply(h);
  116.         final T q2 = q.multiply(q);
  117.         final T p2 = p.multiply(p);

  118.         // A, B, C parameters [Eq. 2.1.6-(1)]
  119.         B = FastMath.sqrt(k2.add(h2).negate().add(1.));
  120.         C = q2.add(p2).add(1);

  121.         // Equinoctial reference frame [Eq. 2.1.4-(1)]
  122.         final T ooC = C.reciprocal();
  123.         final T px2 = p.multiply(2.);
  124.         final T qx2 = q.multiply(2.);
  125.         final T pq2 = px2.multiply(q);
  126.         f = new FieldVector3D<>(ooC, new FieldVector3D<>(p2.negate().add(1.).add(q2), pq2, px2.multiply(I).negate()));
  127.         g = new FieldVector3D<>(ooC, new FieldVector3D<>(pq2.multiply(I), (p2.add(1.).subtract(q2)).multiply(I), qx2));
  128.         w = new FieldVector3D<>(ooC, new FieldVector3D<>(px2, qx2.negate(), (p2.add(q2).negate().add(1.)).multiply(I)));

  129.         // Direction cosines for central body [Eq. 2.1.9-(1)]
  130.         alpha = (T) f.getZ();
  131.         beta  = (T) g.getZ();
  132.         gamma = (T) w.getZ();
  133.     }

  134.     /** Get the date of the orbit.
  135.      * @return the date
  136.      */
  137.     public FieldAbsoluteDate<T> getDate() {
  138.         return date;
  139.     }

  140.     /** Get the definition frame of the orbit.
  141.      * @return the definition frame
  142.      */
  143.     public Frame getFrame() {
  144.         return frame;
  145.     }

  146.     /** Get the eccentricity.
  147.      * @return ecc
  148.      */
  149.     public T getEcc() {
  150.         return ecc;
  151.     }

  152.     /** Get the Keplerian mean motion.
  153.      * @return n
  154.      */
  155.     public T getMeanMotion() {
  156.         return n;
  157.     }

  158.     /** Get the Keplerian period.
  159.      * @return period
  160.      */
  161.     public T getKeplerianPeriod() {
  162.         return period;
  163.     }

  164.     /** Get the semi-major axis.
  165.      * @return the semi-major axis a
  166.      */
  167.     public T getSma() {
  168.         return sma;
  169.     }

  170.     /** Get the x component of eccentricity vector.
  171.      * <p>
  172.      * This element called k in DSST corresponds to ex
  173.      * for the {@link org.orekit.orbits.EquinoctialOrbit}
  174.      * </p>
  175.      * @return k
  176.      */
  177.     public T getK() {
  178.         return k;
  179.     }

  180.     /** Get the y component of eccentricity vector.
  181.      * <p>
  182.      * This element called h in DSST corresponds to ey
  183.      * for the {@link org.orekit.orbits.EquinoctialOrbit}
  184.      * </p>
  185.      * @return h
  186.      */
  187.     public T getH() {
  188.         return h;
  189.     }

  190.     /** Get the x component of inclination vector.
  191.      * <p>
  192.      * This element called q in DSST corresponds to hx
  193.      * for the {@link org.orekit.orbits.EquinoctialOrbit}
  194.      * </p>
  195.      * @return q
  196.      */
  197.     public T getQ() {
  198.         return q;
  199.     }

  200.     /** Get the y component of inclination vector.
  201.      * <p>
  202.      * This element called p in DSST corresponds to hy
  203.      * for the {@link org.orekit.orbits.EquinoctialOrbit}
  204.      * </p>
  205.      * @return p
  206.      */
  207.     public T getP() {
  208.         return p;
  209.     }

  210.     /** Get the mean longitude.
  211.      * @return lm
  212.      */
  213.     public T getLM() {
  214.         return lm;
  215.     }

  216.     /** Get the true longitude.
  217.      * @return lv
  218.      */
  219.     public T getLv() {
  220.         return lv;
  221.     }

  222.     /** Get the eccentric longitude.
  223.      * @return le
  224.      */
  225.     public T getLe() {
  226.         return le;
  227.     }

  228.     /** Get the retrograde factor.
  229.      * @return the retrograde factor I
  230.      */
  231.     public int getRetrogradeFactor() {
  232.         return I;
  233.     }

  234.     /** Get B = sqrt(1 - e²).
  235.      * @return B
  236.      */
  237.     public T getB() {
  238.         return B;
  239.     }

  240.     /** Get C = 1 + p² + q².
  241.      * @return C
  242.      */
  243.     public T getC() {
  244.         return C;
  245.     }

  246.     /** Get equinoctial frame vector f.
  247.      * @return f vector
  248.      */
  249.     public FieldVector3D<T> getVectorF() {
  250.         return f;
  251.     }

  252.     /** Get equinoctial frame vector g.
  253.      * @return g vector
  254.      */
  255.     public FieldVector3D<T> getVectorG() {
  256.         return g;
  257.     }

  258.     /** Get equinoctial frame vector w.
  259.      * @return w vector
  260.      */
  261.     public FieldVector3D<T> getVectorW() {
  262.         return w;
  263.     }

  264.     /** Get direction cosine α for central body.
  265.      * @return α
  266.      */
  267.     public T getAlpha() {
  268.         return alpha;
  269.     }

  270.     /** Get direction cosine β for central body.
  271.      * @return β
  272.      */
  273.     public T getBeta() {
  274.         return beta;
  275.     }

  276.     /** Get direction cosine γ for central body.
  277.      * @return γ
  278.      */
  279.     public T getGamma() {
  280.         return gamma;
  281.     }

  282. }