FieldCircularOrbit.java

  1. /* Copyright 2002-2025 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.orbits;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.Field;
  20. import org.hipparchus.analysis.differentiation.FieldUnivariateDerivative1;
  21. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  22. import org.hipparchus.util.FastMath;
  23. import org.hipparchus.util.FieldSinCos;
  24. import org.hipparchus.util.MathArrays;
  25. import org.orekit.errors.OrekitIllegalArgumentException;
  26. import org.orekit.errors.OrekitInternalError;
  27. import org.orekit.errors.OrekitMessages;
  28. import org.orekit.frames.FieldKinematicTransform;
  29. import org.orekit.frames.Frame;
  30. import org.orekit.time.FieldAbsoluteDate;
  31. import org.orekit.utils.FieldPVCoordinates;
  32. import org.orekit.utils.TimeStampedFieldPVCoordinates;


  33. /**
  34.  * This class handles circular orbital parameters.

  35.  * <p>
  36.  * The parameters used internally are the circular elements which can be
  37.  * related to Keplerian elements as follows:
  38.  *   <ul>
  39.  *     <li>a</li>
  40.  *     <li>e<sub>x</sub> = e cos(ω)</li>
  41.  *     <li>e<sub>y</sub> = e sin(ω)</li>
  42.  *     <li>i</li>
  43.  *     <li>Ω</li>
  44.  *     <li>α<sub>v</sub> = v + ω</li>
  45.  *   </ul>
  46.  * where Ω stands for the Right Ascension of the Ascending Node and
  47.  * α<sub>v</sub> stands for the true latitude argument
  48.  * <p>
  49.  * The conversion equations from and to Keplerian elements given above hold only
  50.  * when both sides are unambiguously defined, i.e. when orbit is neither equatorial
  51.  * nor circular. When orbit is circular (but not equatorial), the circular
  52.  * parameters are still unambiguously defined whereas some Keplerian elements
  53.  * (more precisely ω and Ω) become ambiguous. When orbit is equatorial,
  54.  * neither the Keplerian nor the circular parameters can be defined unambiguously.
  55.  * {@link EquinoctialOrbit equinoctial orbits} is the recommended way to represent
  56.  * orbits.
  57.  * </p>
  58.  * <p>
  59.  * The instance <code>CircularOrbit</code> is guaranteed to be immutable.
  60.  * </p>
  61.  * @see    Orbit
  62.  * @see    KeplerianOrbit
  63.  * @see    CartesianOrbit
  64.  * @see    EquinoctialOrbit
  65.  * @author Luc Maisonobe
  66.  * @author Fabien Maussion
  67.  * @author V&eacute;ronique Pommier-Maurussane
  68.  * @since 9.0
  69.  * @param <T> type of the field elements
  70.  */

  71. public class FieldCircularOrbit<T extends CalculusFieldElement<T>> extends FieldOrbit<T>
  72.         implements PositionAngleBased<FieldCircularOrbit<T>> {

  73.     /** Semi-major axis (m). */
  74.     private final T a;

  75.     /** First component of the circular eccentricity vector. */
  76.     private final T ex;

  77.     /** Second component of the circular eccentricity vector. */
  78.     private final T ey;

  79.     /** Inclination (rad). */
  80.     private final T i;

  81.     /** Right Ascension of Ascending Node (rad). */
  82.     private final T raan;

  83.     /** Cached latitude argument (rad). */
  84.     private final T cachedAlpha;

  85.     /** Type of cached position angle (latitude argument). */
  86.     private final PositionAngleType cachedPositionAngleType;

  87.     /** Semi-major axis derivative (m/s). */
  88.     private final T aDot;

  89.     /** First component of the circular eccentricity vector derivative. */
  90.     private final T exDot;

  91.     /** Second component of the circular eccentricity vector derivative. */
  92.     private final T eyDot;

  93.     /** Inclination derivative (rad/s). */
  94.     private final T iDot;

  95.     /** Right Ascension of Ascending Node derivative (rad/s). */
  96.     private final T raanDot;

  97.     /** True latitude argument derivative (rad/s). */
  98.     private final T cachedAlphaDot;

  99.     /** Partial Cartesian coordinates (position and velocity are valid, acceleration may be missing). */
  100.     private FieldPVCoordinates<T> partialPV;

  101.     /** Creates a new instance.
  102.      * @param a  semi-major axis (m)
  103.      * @param ex e cos(ω), first component of circular eccentricity vector
  104.      * @param ey e sin(ω), second component of circular eccentricity vector
  105.      * @param i inclination (rad)
  106.      * @param raan right ascension of ascending node (Ω, rad)
  107.      * @param alpha  an + ω, mean, eccentric or true latitude argument (rad)
  108.      * @param type type of latitude argument
  109.      * @param cachedPositionAngleType type of cached latitude argument
  110.      * @param frame the frame in which are defined the parameters
  111.      * (<em>must</em> be a {@link Frame#isPseudoInertial pseudo-inertial frame})
  112.      * @param date date of the orbital parameters
  113.      * @param mu central attraction coefficient (m³/s²)
  114.      * @exception IllegalArgumentException if eccentricity is equal to 1 or larger or
  115.      * if frame is not a {@link Frame#isPseudoInertial pseudo-inertial frame}
  116.      * @since 12.1
  117.      */
  118.     public FieldCircularOrbit(final T a, final T ex, final T ey, final T i, final T raan,
  119.                               final T alpha, final PositionAngleType type,
  120.                               final PositionAngleType cachedPositionAngleType,
  121.                               final Frame frame, final FieldAbsoluteDate<T> date, final T mu)
  122.         throws IllegalArgumentException {
  123.         this(a, ex, ey, i, raan, alpha,
  124.              a.getField().getZero(), a.getField().getZero(), a.getField().getZero(), a.getField().getZero(), a.getField().getZero(),
  125.              computeKeplerianAlphaDot(type, a, ex, ey, mu, alpha, type), type, cachedPositionAngleType, frame, date, mu);
  126.     }

  127.     /** Creates a new instance without derivatives and with cached position angle same as value inputted.
  128.      * @param a  semi-major axis (m)
  129.      * @param ex e cos(ω), first component of circular eccentricity vector
  130.      * @param ey e sin(ω), second component of circular eccentricity vector
  131.      * @param i inclination (rad)
  132.      * @param raan right ascension of ascending node (Ω, rad)
  133.      * @param alpha  an + ω, mean, eccentric or true latitude argument (rad)
  134.      * @param type type of latitude argument
  135.      * @param frame the frame in which are defined the parameters
  136.      * (<em>must</em> be a {@link Frame#isPseudoInertial pseudo-inertial frame})
  137.      * @param date date of the orbital parameters
  138.      * @param mu central attraction coefficient (m³/s²)
  139.      * @exception IllegalArgumentException if eccentricity is equal to 1 or larger or
  140.      * if frame is not a {@link Frame#isPseudoInertial pseudo-inertial frame}
  141.      */
  142.     public FieldCircularOrbit(final T a, final T ex, final T ey, final T i, final T raan,
  143.                               final T alpha, final PositionAngleType type,
  144.                               final Frame frame, final FieldAbsoluteDate<T> date, final T mu)
  145.             throws IllegalArgumentException {
  146.         this(a, ex, ey, i, raan, alpha, type, type, frame, date, mu);
  147.     }

  148.     /** Creates a new instance.
  149.      * @param a  semi-major axis (m)
  150.      * @param ex e cos(ω), first component of circular eccentricity vector
  151.      * @param ey e sin(ω), second component of circular eccentricity vector
  152.      * @param i inclination (rad)
  153.      * @param raan right ascension of ascending node (Ω, rad)
  154.      * @param alpha  an + ω, mean, eccentric or true latitude argument (rad)
  155.      * @param aDot  semi-major axis derivative (m/s)
  156.      * @param exDot d(e cos(ω))/dt, first component of circular eccentricity vector derivative
  157.      * @param eyDot d(e sin(ω))/dt, second component of circular eccentricity vector derivative
  158.      * @param iDot inclination  derivative(rad/s)
  159.      * @param raanDot right ascension of ascending node derivative (rad/s)
  160.      * @param alphaDot  d(an + ω), mean, eccentric or true latitude argument derivative (rad/s)
  161.      * @param type type of latitude argument
  162.      * @param frame the frame in which are defined the parameters
  163.      * (<em>must</em> be a {@link Frame#isPseudoInertial pseudo-inertial frame})
  164.      * @param date date of the orbital parameters
  165.      * @param mu central attraction coefficient (m³/s²)
  166.      * @exception IllegalArgumentException if eccentricity is equal to 1 or larger or
  167.      * if frame is not a {@link Frame#isPseudoInertial pseudo-inertial frame}
  168.      */
  169.     public FieldCircularOrbit(final T a, final T ex, final T ey,
  170.                               final T i, final T raan, final T alpha,
  171.                               final T aDot, final T exDot, final T eyDot,
  172.                               final T iDot, final T raanDot, final T alphaDot, final PositionAngleType type,
  173.                               final Frame frame, final FieldAbsoluteDate<T> date, final T mu)
  174.             throws IllegalArgumentException {
  175.         this(a, ex, ey, i, raan, alpha, aDot, exDot, eyDot, iDot, raanDot, alphaDot, type, type, frame, date, mu);
  176.     }

  177.     /** Creates a new instance.
  178.      * @param a  semi-major axis (m)
  179.      * @param ex e cos(ω), first component of circular eccentricity vector
  180.      * @param ey e sin(ω), second component of circular eccentricity vector
  181.      * @param i inclination (rad)
  182.      * @param raan right ascension of ascending node (Ω, rad)
  183.      * @param alpha  an + ω, mean, eccentric or true latitude argument (rad)
  184.      * @param aDot  semi-major axis derivative (m/s)
  185.      * @param exDot d(e cos(ω))/dt, first component of circular eccentricity vector derivative
  186.      * @param eyDot d(e sin(ω))/dt, second component of circular eccentricity vector derivative
  187.      * @param iDot inclination  derivative(rad/s)
  188.      * @param raanDot right ascension of ascending node derivative (rad/s)
  189.      * @param alphaDot  d(an + ω), mean, eccentric or true latitude argument derivative (rad/s)
  190.      * @param type type of latitude argument
  191.      * @param cachedPositionAngleType type of cached latitude argument
  192.      * @param frame the frame in which are defined the parameters
  193.      * (<em>must</em> be a {@link Frame#isPseudoInertial pseudo-inertial frame})
  194.      * @param date date of the orbital parameters
  195.      * @param mu central attraction coefficient (m³/s²)
  196.      * @exception IllegalArgumentException if eccentricity is equal to 1 or larger or
  197.      * if frame is not a {@link Frame#isPseudoInertial pseudo-inertial frame}
  198.      * @since 12.1
  199.      */
  200.     public FieldCircularOrbit(final T a, final T ex, final T ey,
  201.                               final T i, final T raan, final T alpha,
  202.                               final T aDot, final T exDot, final T eyDot,
  203.                               final T iDot, final T raanDot, final T alphaDot,
  204.                               final PositionAngleType type, final PositionAngleType cachedPositionAngleType,
  205.                               final Frame frame, final FieldAbsoluteDate<T> date, final T mu)
  206.         throws IllegalArgumentException {
  207.         super(frame, date, mu);
  208.         if (ex.getReal() * ex.getReal() + ey.getReal() * ey.getReal() >= 1.0) {
  209.             throw new OrekitIllegalArgumentException(OrekitMessages.HYPERBOLIC_ORBIT_NOT_HANDLED_AS,
  210.                                                      getClass().getName());
  211.         }

  212.         this.a       =  a;
  213.         this.aDot    =  aDot;
  214.         this.ex      = ex;
  215.         this.exDot   = exDot;
  216.         this.ey      = ey;
  217.         this.eyDot   = eyDot;
  218.         this.i       = i;
  219.         this.iDot    = iDot;
  220.         this.raan    = raan;
  221.         this.raanDot = raanDot;
  222.         this.cachedPositionAngleType = cachedPositionAngleType;

  223.         final FieldUnivariateDerivative1<T> alphaUD = initializeCachedAlpha(alpha, alphaDot, type);
  224.         this.cachedAlpha = alphaUD.getValue();
  225.         this.cachedAlphaDot = alphaUD.getFirstDerivative();

  226.         partialPV   = null;

  227.     }

  228.     /** Constructor from Cartesian parameters.
  229.      *
  230.      * <p> The acceleration provided in {@code FieldPVCoordinates} is accessible using
  231.      * {@link #getPVCoordinates()} and {@link #getPVCoordinates(Frame)}. All other methods
  232.      * use {@code mu} and the position to compute the acceleration, including
  233.      * {@link #shiftedBy(CalculusFieldElement)} and {@link #getPVCoordinates(FieldAbsoluteDate, Frame)}.
  234.      *
  235.      * @param pvCoordinates the {@link FieldPVCoordinates} in inertial frame
  236.      * @param frame the frame in which are defined the {@link FieldPVCoordinates}
  237.      * (<em>must</em> be a {@link Frame#isPseudoInertial pseudo-inertial frame})
  238.      * @param mu central attraction coefficient (m³/s²)
  239.      * @exception IllegalArgumentException if frame is not a {@link
  240.      * Frame#isPseudoInertial pseudo-inertial frame}
  241.      */
  242.     public FieldCircularOrbit(final TimeStampedFieldPVCoordinates<T> pvCoordinates,
  243.                               final Frame frame, final T mu)
  244.         throws IllegalArgumentException {
  245.         super(pvCoordinates, frame, mu);
  246.         this.cachedPositionAngleType = PositionAngleType.TRUE;

  247.         // compute semi-major axis
  248.         final FieldVector3D<T> pvP = pvCoordinates.getPosition();
  249.         final FieldVector3D<T> pvV = pvCoordinates.getVelocity();
  250.         final FieldVector3D<T> pvA = pvCoordinates.getAcceleration();
  251.         final T r2 = pvP.getNormSq();
  252.         final T r  = r2.sqrt();
  253.         final T V2 = pvV.getNormSq();
  254.         final T rV2OnMu = r.multiply(V2).divide(mu);

  255.         a = r.divide(rV2OnMu.negate().add(2));

  256.         if (!isElliptical()) {
  257.             throw new OrekitIllegalArgumentException(OrekitMessages.HYPERBOLIC_ORBIT_NOT_HANDLED_AS,
  258.                                                      getClass().getName());
  259.         }

  260.         // compute inclination
  261.         final FieldVector3D<T> momentum = pvCoordinates.getMomentum();
  262.         final FieldVector3D<T> plusK = FieldVector3D.getPlusK(r.getField());
  263.         i = FieldVector3D.angle(momentum, plusK);

  264.         // compute right ascension of ascending node
  265.         final FieldVector3D<T> node  = FieldVector3D.crossProduct(plusK, momentum);
  266.         raan = node.getY().atan2(node.getX());

  267.         // 2D-coordinates in the canonical frame
  268.         final FieldSinCos<T> scRaan = FastMath.sinCos(raan);
  269.         final FieldSinCos<T> scI    = FastMath.sinCos(i);
  270.         final T xP      = pvP.getX();
  271.         final T yP      = pvP.getY();
  272.         final T zP      = pvP.getZ();
  273.         final T x2      = (xP.multiply(scRaan.cos()).add(yP .multiply(scRaan.sin()))).divide(a);
  274.         final T y2      = (yP.multiply(scRaan.cos()).subtract(xP.multiply(scRaan.sin()))).multiply(scI.cos()).add(zP.multiply(scI.sin())).divide(a);

  275.         // compute eccentricity vector
  276.         final T eSE    = FieldVector3D.dotProduct(pvP, pvV).divide(a.multiply(mu).sqrt());
  277.         final T eCE    = rV2OnMu.subtract(1);
  278.         final T e2     = eCE.multiply(eCE).add(eSE.multiply(eSE));
  279.         final T f      = eCE.subtract(e2);
  280.         final T g      = eSE.multiply(e2.negate().add(1).sqrt());
  281.         final T aOnR   = a.divide(r);
  282.         final T a2OnR2 = aOnR.square();
  283.         ex = a2OnR2.multiply(f.multiply(x2).add(g.multiply(y2)));
  284.         ey = a2OnR2.multiply(f.multiply(y2).subtract(g.multiply(x2)));

  285.         // compute latitude argument
  286.         final T beta = (ex.multiply(ex).add(ey.multiply(ey)).negate().add(1)).sqrt().add(1).reciprocal();
  287.         cachedAlpha = FieldCircularLatitudeArgumentUtility.eccentricToTrue(ex, ey, y2.add(ey).add(eSE.multiply(beta).multiply(ex)).atan2(x2.add(ex).subtract(eSE.multiply(beta).multiply(ey)))
  288.         );

  289.         partialPV = pvCoordinates;

  290.         if (hasNonKeplerianAcceleration(pvCoordinates, mu)) {
  291.             // we have a relevant acceleration, we can compute derivatives

  292.             final T[][] jacobian = MathArrays.buildArray(a.getField(), 6, 6);
  293.             getJacobianWrtCartesian(PositionAngleType.MEAN, jacobian);

  294.             final FieldVector3D<T> keplerianAcceleration    = new FieldVector3D<>(r.multiply(r2).reciprocal().multiply(mu.negate()), pvP);
  295.             final FieldVector3D<T> nonKeplerianAcceleration = pvA.subtract(keplerianAcceleration);
  296.             final T   aX                       = nonKeplerianAcceleration.getX();
  297.             final T   aY                       = nonKeplerianAcceleration.getY();
  298.             final T   aZ                       = nonKeplerianAcceleration.getZ();
  299.             aDot    = jacobian[0][3].multiply(aX).add(jacobian[0][4].multiply(aY)).add(jacobian[0][5].multiply(aZ));
  300.             exDot   = jacobian[1][3].multiply(aX).add(jacobian[1][4].multiply(aY)).add(jacobian[1][5].multiply(aZ));
  301.             eyDot   = jacobian[2][3].multiply(aX).add(jacobian[2][4].multiply(aY)).add(jacobian[2][5].multiply(aZ));
  302.             iDot    = jacobian[3][3].multiply(aX).add(jacobian[3][4].multiply(aY)).add(jacobian[3][5].multiply(aZ));
  303.             raanDot = jacobian[4][3].multiply(aX).add(jacobian[4][4].multiply(aY)).add(jacobian[4][5].multiply(aZ));

  304.             // in order to compute true anomaly derivative, we must compute
  305.             // mean anomaly derivative including Keplerian motion and convert to true anomaly
  306.             final T alphaMDot = getKeplerianMeanMotion().
  307.                                 add(jacobian[5][3].multiply(aX)).add(jacobian[5][4].multiply(aY)).add(jacobian[5][5].multiply(aZ));
  308.             final FieldUnivariateDerivative1<T> exUD     = new FieldUnivariateDerivative1<>(ex, exDot);
  309.             final FieldUnivariateDerivative1<T> eyUD     = new FieldUnivariateDerivative1<>(ey, eyDot);
  310.             final FieldUnivariateDerivative1<T> alphaMUD = new FieldUnivariateDerivative1<>(getAlphaM(), alphaMDot);
  311.             final FieldUnivariateDerivative1<T> alphavUD = FieldCircularLatitudeArgumentUtility.meanToTrue(exUD, eyUD, alphaMUD);
  312.             cachedAlphaDot = alphavUD.getFirstDerivative();

  313.         } else {
  314.             // acceleration is either almost zero or NaN,
  315.             // we assume acceleration was not known
  316.             // we don't set up derivatives
  317.             aDot      = getZero();
  318.             exDot     = getZero();
  319.             eyDot     = getZero();
  320.             iDot      = getZero();
  321.             raanDot   = getZero();
  322.             cachedAlphaDot = computeKeplerianAlphaDot(cachedPositionAngleType, a, ex, ey, mu, cachedAlpha, cachedPositionAngleType);
  323.         }

  324.     }

  325.     /** Constructor from Cartesian parameters.
  326.      *
  327.      * <p> The acceleration provided in {@code FieldPVCoordinates} is accessible using
  328.      * {@link #getPVCoordinates()} and {@link #getPVCoordinates(Frame)}. All other methods
  329.      * use {@code mu} and the position to compute the acceleration, including
  330.      * {@link #shiftedBy(CalculusFieldElement)} and {@link #getPVCoordinates(FieldAbsoluteDate, Frame)}.
  331.      *
  332.      * @param PVCoordinates the {@link FieldPVCoordinates} in inertial frame
  333.      * @param frame the frame in which are defined the {@link FieldPVCoordinates}
  334.      * (<em>must</em> be a {@link Frame#isPseudoInertial pseudo-inertial frame})
  335.      * @param date date of the orbital parameters
  336.      * @param mu central attraction coefficient (m³/s²)
  337.      * @exception IllegalArgumentException if frame is not a {@link
  338.      * Frame#isPseudoInertial pseudo-inertial frame}
  339.      */
  340.     public FieldCircularOrbit(final FieldPVCoordinates<T> PVCoordinates, final Frame frame,
  341.                               final FieldAbsoluteDate<T> date, final T mu)
  342.         throws IllegalArgumentException {
  343.         this(new TimeStampedFieldPVCoordinates<>(date, PVCoordinates), frame, mu);
  344.     }

  345.     /** Constructor from any kind of orbital parameters.
  346.      * @param op orbital parameters to copy
  347.      */
  348.     public FieldCircularOrbit(final FieldOrbit<T> op) {
  349.         super(op.getFrame(), op.getDate(), op.getMu());
  350.         a    = op.getA();
  351.         i    = op.getI();
  352.         final T hx = op.getHx();
  353.         final T hy = op.getHy();
  354.         final T h2 = hx.square().add(hy.square());
  355.         final T h  = h2.sqrt();
  356.         raan = hy.atan2(hx);
  357.         final FieldSinCos<T> scRaan = FastMath.sinCos(raan);
  358.         final T cosRaan = h.getReal() == 0 ? scRaan.cos() : hx.divide(h);
  359.         final T sinRaan = h.getReal() == 0 ? scRaan.sin() : hy.divide(h);
  360.         final T equiEx = op.getEquinoctialEx();
  361.         final T equiEy = op.getEquinoctialEy();
  362.         ex   = equiEx.multiply(cosRaan).add(equiEy.multiply(sinRaan));
  363.         ey   = equiEy.multiply(cosRaan).subtract(equiEx.multiply(sinRaan));
  364.         cachedPositionAngleType = PositionAngleType.TRUE;
  365.         cachedAlpha = op.getLv().subtract(raan);

  366.         if (op.hasNonKeplerianAcceleration()) {
  367.             aDot      = op.getADot();
  368.             final T      hxDot = op.getHxDot();
  369.             final T      hyDot = op.getHyDot();
  370.             iDot      = cosRaan.multiply(hxDot).add(sinRaan.multiply(hyDot)).multiply(2).divide(h2.add(1));
  371.             raanDot   = hx.multiply(hyDot).subtract(hy.multiply(hxDot)).divide(h2);
  372.             final T equiExDot = op.getEquinoctialExDot();
  373.             final T equiEyDot = op.getEquinoctialEyDot();
  374.             exDot     = equiExDot.add(equiEy.multiply(raanDot)).multiply(cosRaan).
  375.                         add(equiEyDot.subtract(equiEx.multiply(raanDot)).multiply(sinRaan));
  376.             eyDot     = equiEyDot.subtract(equiEx.multiply(raanDot)).multiply(cosRaan).
  377.                         subtract(equiExDot.add(equiEy.multiply(raanDot)).multiply(sinRaan));
  378.             cachedAlphaDot = op.getLvDot().subtract(raanDot);
  379.         } else {
  380.             aDot      = getZero();
  381.             exDot     = getZero();
  382.             eyDot     = getZero();
  383.             iDot      = getZero();
  384.             raanDot   = getZero();
  385.             cachedAlphaDot = computeKeplerianAlphaDot(cachedPositionAngleType, a, ex, ey, op.getMu(), cachedAlpha, cachedPositionAngleType);
  386.         }

  387.         partialPV = null;

  388.     }

  389.     /** Constructor from Field and CircularOrbit.
  390.      * <p>Build a FieldCircularOrbit from non-Field CircularOrbit.</p>
  391.      * @param field CalculusField to base object on
  392.      * @param op non-field orbit with only "constant" terms
  393.      * @since 12.0
  394.      */
  395.     public FieldCircularOrbit(final Field<T> field, final CircularOrbit op) {
  396.         super(op.getFrame(), new FieldAbsoluteDate<>(field, op.getDate()), field.getZero().newInstance(op.getMu()));

  397.         a    = getZero().newInstance(op.getA());
  398.         i    = getZero().newInstance(op.getI());
  399.         raan = getZero().newInstance(op.getRightAscensionOfAscendingNode());
  400.         ex   = getZero().newInstance(op.getCircularEx());
  401.         ey   = getZero().newInstance(op.getCircularEy());
  402.         cachedPositionAngleType = op.getCachedPositionAngleType();
  403.         cachedAlpha = getZero().newInstance(op.getAlpha(cachedPositionAngleType));

  404.         aDot      = getZero().newInstance(op.getADot());
  405.         iDot      = getZero().newInstance(op.getIDot());
  406.         raanDot   = getZero().newInstance(op.getRightAscensionOfAscendingNodeDot());
  407.         exDot     = getZero().newInstance(op.getCircularExDot());
  408.         eyDot     = getZero().newInstance(op.getCircularEyDot());
  409.         cachedAlphaDot = getZero().newInstance(op.getAlphaDot(cachedPositionAngleType));

  410.         partialPV = null;

  411.     }

  412.     /** Constructor from Field and Orbit.
  413.      * <p>Build a FieldCircularOrbit from any non-Field Orbit.</p>
  414.      * @param field CalculusField to base object on
  415.      * @param op non-field orbit with only "constant" terms
  416.      * @since 12.0
  417.      */
  418.     public FieldCircularOrbit(final Field<T> field, final Orbit op) {
  419.         this(field, (CircularOrbit) OrbitType.CIRCULAR.convertType(op));
  420.     }

  421.     /** {@inheritDoc} */
  422.     @Override
  423.     public OrbitType getType() {
  424.         return OrbitType.CIRCULAR;
  425.     }

  426.     /** {@inheritDoc} */
  427.     @Override
  428.     public T getA() {
  429.         return a;
  430.     }

  431.     /** {@inheritDoc} */
  432.     @Override
  433.     public T getADot() {
  434.         return aDot;
  435.     }

  436.     /** {@inheritDoc} */
  437.     @Override
  438.     public T getEquinoctialEx() {
  439.         final FieldSinCos<T> sc = FastMath.sinCos(raan);
  440.         return ex.multiply(sc.cos()).subtract(ey.multiply(sc.sin()));
  441.     }

  442.     /** {@inheritDoc} */
  443.     @Override
  444.     public T getEquinoctialExDot() {
  445.         if (!hasNonKeplerianRates()) {
  446.             return getZero();
  447.         }
  448.         final FieldSinCos<T> sc = FastMath.sinCos(raan);
  449.         return exDot.subtract(ey.multiply(raanDot)).multiply(sc.cos()).
  450.                subtract(eyDot.add(ex.multiply(raanDot)).multiply(sc.sin()));

  451.     }

  452.     /** {@inheritDoc} */
  453.     @Override
  454.     public T getEquinoctialEy() {
  455.         final FieldSinCos<T> sc = FastMath.sinCos(raan);
  456.         return ey.multiply(sc.cos()).add(ex.multiply(sc.sin()));
  457.     }

  458.     /** {@inheritDoc} */
  459.     @Override
  460.     public T getEquinoctialEyDot() {
  461.         if (!hasNonKeplerianRates()) {
  462.             return getZero();
  463.         }
  464.         final FieldSinCos<T> sc = FastMath.sinCos(raan);
  465.         return eyDot.add(ex.multiply(raanDot)).multiply(sc.cos()).
  466.                add(exDot.subtract(ey.multiply(raanDot)).multiply(sc.sin()));

  467.     }

  468.     /** Get the first component of the circular eccentricity vector.
  469.      * @return ex = e cos(ω), first component of the circular eccentricity vector
  470.      */
  471.     public T getCircularEx() {
  472.         return ex;
  473.     }

  474.     /** Get the first component of the circular eccentricity vector derivative.
  475.      * @return d(ex)/dt = d(e cos(ω))/dt, first component of the circular eccentricity vector derivative
  476.      */
  477.     public T getCircularExDot() {
  478.         return exDot;
  479.     }

  480.     /** Get the second component of the circular eccentricity vector.
  481.      * @return ey = e sin(ω), second component of the circular eccentricity vector
  482.      */
  483.     public T getCircularEy() {
  484.         return ey;
  485.     }

  486.     /** Get the second component of the circular eccentricity vector derivative.
  487.      * @return d(ey)/dt = d(e sin(ω))/dt, second component of the circular eccentricity vector derivative
  488.      */
  489.     public T getCircularEyDot() {
  490.         return eyDot;
  491.     }

  492.     /** {@inheritDoc} */
  493.     @Override
  494.     public T getHx() {
  495.         // Check for equatorial retrograde orbit
  496.         if (FastMath.abs(i.subtract(i.getPi()).getReal()) < 1.0e-10) {
  497.             return getZero().add(Double.NaN);
  498.         }
  499.         return raan.cos().multiply(i.divide(2).tan());
  500.     }

  501.     /** {@inheritDoc} */
  502.     @Override
  503.     public T getHxDot() {

  504.         // Check for equatorial retrograde orbit
  505.         if (FastMath.abs(i.subtract(i.getPi()).getReal()) < 1.0e-10) {
  506.             return getZero().add(Double.NaN);
  507.         }
  508.         if (!hasNonKeplerianRates()) {
  509.             return getZero();
  510.         }

  511.         final FieldSinCos<T> sc = FastMath.sinCos(raan);
  512.         final T tan             = i.multiply(0.5).tan();
  513.         return sc.cos().multiply(0.5).multiply(tan.multiply(tan).add(1)).multiply(iDot).
  514.                subtract(sc.sin().multiply(tan).multiply(raanDot));

  515.     }

  516.     /** {@inheritDoc} */
  517.     @Override
  518.     public T getHy() {
  519.         // Check for equatorial retrograde orbit
  520.         if (FastMath.abs(i.subtract(i.getPi()).getReal()) < 1.0e-10) {
  521.             return getZero().add(Double.NaN);
  522.         }
  523.         return raan.sin().multiply(i.divide(2).tan());
  524.     }

  525.     /** {@inheritDoc} */
  526.     @Override
  527.     public T getHyDot() {

  528.         // Check for equatorial retrograde orbit
  529.         if (FastMath.abs(i.subtract(i.getPi()).getReal()) < 1.0e-10) {
  530.             return getZero().add(Double.NaN);
  531.         }
  532.         if (!hasNonKeplerianRates()) {
  533.             return getZero();
  534.         }

  535.         final FieldSinCos<T> sc = FastMath.sinCos(raan);
  536.         final T tan     = i.multiply(0.5).tan();
  537.         return sc.sin().multiply(0.5).multiply(tan.multiply(tan).add(1)).multiply(iDot).
  538.                add(sc.cos().multiply(tan).multiply(raanDot));

  539.     }

  540.     /** Get the true latitude argument.
  541.      * @return v + ω true latitude argument (rad)
  542.      */
  543.     public T getAlphaV() {
  544.         switch (cachedPositionAngleType) {
  545.             case TRUE:
  546.                 return cachedAlpha;

  547.             case ECCENTRIC:
  548.                 return FieldCircularLatitudeArgumentUtility.eccentricToTrue(ex, ey, cachedAlpha);

  549.             case MEAN:
  550.                 return FieldCircularLatitudeArgumentUtility.meanToTrue(ex, ey, cachedAlpha);

  551.             default:
  552.                 throw new OrekitInternalError(null);
  553.         }
  554.     }

  555.     /** Get the true latitude argument derivative.
  556.      * @return d(v + ω)/dt true latitude argument derivative (rad/s)
  557.      */
  558.     public T getAlphaVDot() {

  559.         switch (cachedPositionAngleType) {
  560.             case ECCENTRIC:
  561.                 final FieldUnivariateDerivative1<T> alphaEUD = new FieldUnivariateDerivative1<>(cachedAlpha, cachedAlphaDot);
  562.                 final FieldUnivariateDerivative1<T> exUD     = new FieldUnivariateDerivative1<>(ex,     exDot);
  563.                 final FieldUnivariateDerivative1<T> eyUD     = new FieldUnivariateDerivative1<>(ey,     eyDot);
  564.                 final FieldUnivariateDerivative1<T> alphaVUD = FieldCircularLatitudeArgumentUtility.eccentricToTrue(exUD, eyUD,
  565.                         alphaEUD);
  566.                 return alphaVUD.getFirstDerivative();

  567.             case TRUE:
  568.                 return cachedAlphaDot;

  569.             case MEAN:
  570.                 final FieldUnivariateDerivative1<T> alphaMUD = new FieldUnivariateDerivative1<>(cachedAlpha, cachedAlphaDot);
  571.                 final FieldUnivariateDerivative1<T> exUD2    = new FieldUnivariateDerivative1<>(ex,     exDot);
  572.                 final FieldUnivariateDerivative1<T> eyUD2    = new FieldUnivariateDerivative1<>(ey,     eyDot);
  573.                 final FieldUnivariateDerivative1<T> alphaVUD2 = FieldCircularLatitudeArgumentUtility.meanToTrue(exUD2,
  574.                         eyUD2, alphaMUD);
  575.                 return alphaVUD2.getFirstDerivative();

  576.             default:
  577.                 throw new OrekitInternalError(null);
  578.         }
  579.     }

  580.     /** Get the eccentric latitude argument.
  581.      * @return E + ω eccentric latitude argument (rad)
  582.      */
  583.     public T getAlphaE() {
  584.         switch (cachedPositionAngleType) {
  585.             case TRUE:
  586.                 return FieldCircularLatitudeArgumentUtility.trueToEccentric(ex, ey, cachedAlpha);

  587.             case ECCENTRIC:
  588.                 return cachedAlpha;

  589.             case MEAN:
  590.                 return FieldCircularLatitudeArgumentUtility.meanToEccentric(ex, ey, cachedAlpha);

  591.             default:
  592.                 throw new OrekitInternalError(null);
  593.         }
  594.     }

  595.     /** Get the eccentric latitude argument derivative.
  596.      * @return d(E + ω)/dt eccentric latitude argument derivative (rad/s)
  597.      */
  598.     public T getAlphaEDot() {

  599.         switch (cachedPositionAngleType) {
  600.             case TRUE:
  601.                 final FieldUnivariateDerivative1<T> alphaVUD = new FieldUnivariateDerivative1<>(cachedAlpha, cachedAlphaDot);
  602.                 final FieldUnivariateDerivative1<T> exUD = new FieldUnivariateDerivative1<>(ex, exDot);
  603.                 final FieldUnivariateDerivative1<T> eyUD = new FieldUnivariateDerivative1<>(ey, eyDot);
  604.                 final FieldUnivariateDerivative1<T> alphaEUD = FieldCircularLatitudeArgumentUtility.trueToEccentric(exUD, eyUD,
  605.                         alphaVUD);
  606.                 return alphaEUD.getFirstDerivative();

  607.             case ECCENTRIC:
  608.                 return cachedAlphaDot;

  609.             case MEAN:
  610.                 final FieldUnivariateDerivative1<T> alphaMUD = new FieldUnivariateDerivative1<>(cachedAlpha, cachedAlphaDot);
  611.                 final FieldUnivariateDerivative1<T> exUD2 = new FieldUnivariateDerivative1<>(ex, exDot);
  612.                 final FieldUnivariateDerivative1<T> eyUD2 = new FieldUnivariateDerivative1<>(ey, eyDot);
  613.                 final FieldUnivariateDerivative1<T> alphaVUD2 = FieldCircularLatitudeArgumentUtility.meanToEccentric(exUD2,
  614.                         eyUD2, alphaMUD);
  615.                 return alphaVUD2.getFirstDerivative();

  616.             default:
  617.                 throw new OrekitInternalError(null);
  618.         }

  619.     }

  620.     /** Get the mean latitude argument.
  621.      * @return M + ω mean latitude argument (rad)
  622.      */
  623.     public T getAlphaM() {
  624.         switch (cachedPositionAngleType) {
  625.             case TRUE:
  626.                 return FieldCircularLatitudeArgumentUtility.trueToMean(ex, ey, cachedAlpha);

  627.             case MEAN:
  628.                 return cachedAlpha;

  629.             case ECCENTRIC:
  630.                 return FieldCircularLatitudeArgumentUtility.eccentricToMean(ex, ey, cachedAlpha);

  631.             default:
  632.                 throw new OrekitInternalError(null);
  633.         }
  634.     }

  635.     /** Get the mean latitude argument derivative.
  636.      * @return d(M + ω)/dt mean latitude argument derivative (rad/s)
  637.      */
  638.     public T getAlphaMDot() {

  639.         switch (cachedPositionAngleType) {
  640.             case TRUE:
  641.                 final FieldUnivariateDerivative1<T> alphaVUD = new FieldUnivariateDerivative1<>(cachedAlpha, cachedAlphaDot);
  642.                 final FieldUnivariateDerivative1<T> exUD = new FieldUnivariateDerivative1<>(ex, exDot);
  643.                 final FieldUnivariateDerivative1<T> eyUD = new FieldUnivariateDerivative1<>(ey, eyDot);
  644.                 final FieldUnivariateDerivative1<T> alphaMUD = FieldCircularLatitudeArgumentUtility.trueToMean(exUD, eyUD,
  645.                         alphaVUD);
  646.                 return alphaMUD.getFirstDerivative();

  647.             case MEAN:
  648.                 return cachedAlphaDot;

  649.             case ECCENTRIC:
  650.                 final FieldUnivariateDerivative1<T> alphaEUD = new FieldUnivariateDerivative1<>(cachedAlpha, cachedAlphaDot);
  651.                 final FieldUnivariateDerivative1<T> exUD2 = new FieldUnivariateDerivative1<>(ex, exDot);
  652.                 final FieldUnivariateDerivative1<T> eyUD2 = new FieldUnivariateDerivative1<>(ey, eyDot);
  653.                 final FieldUnivariateDerivative1<T> alphaMUD2 = FieldCircularLatitudeArgumentUtility.eccentricToMean(exUD2,
  654.                         eyUD2, alphaEUD);
  655.                 return alphaMUD2.getFirstDerivative();

  656.             default:
  657.                 throw new OrekitInternalError(null);
  658.         }
  659.     }

  660.     /** Get the latitude argument.
  661.      * @param type type of the angle
  662.      * @return latitude argument (rad)
  663.      */
  664.     public T getAlpha(final PositionAngleType type) {
  665.         return (type == PositionAngleType.MEAN) ? getAlphaM() :
  666.                                               ((type == PositionAngleType.ECCENTRIC) ? getAlphaE() :
  667.                                                                                    getAlphaV());
  668.     }

  669.     /** Get the latitude argument derivative.
  670.      * @param type type of the angle
  671.      * @return latitude argument derivative (rad/s)
  672.      */
  673.     public T getAlphaDot(final PositionAngleType type) {
  674.         return (type == PositionAngleType.MEAN) ? getAlphaMDot() :
  675.                                               ((type == PositionAngleType.ECCENTRIC) ? getAlphaEDot() :
  676.                                                                                    getAlphaVDot());
  677.     }

  678.     /** {@inheritDoc} */
  679.     @Override
  680.     public T getE() {
  681.         return ex.multiply(ex).add(ey.multiply(ey)).sqrt();
  682.     }

  683.     /** {@inheritDoc} */
  684.     @Override
  685.     public T getEDot() {

  686.         return ex.multiply(exDot).add(ey.multiply(eyDot)).divide(getE());

  687.     }

  688.     /** {@inheritDoc} */
  689.     @Override
  690.     public T getI() {
  691.         return i;
  692.     }

  693.     /** {@inheritDoc} */
  694.     @Override
  695.     public T getIDot() {
  696.         return iDot;
  697.     }

  698.     /** Get the right ascension of the ascending node.
  699.      * @return right ascension of the ascending node (rad)
  700.      */
  701.     public T getRightAscensionOfAscendingNode() {
  702.         return raan;
  703.     }

  704.     /** Get the right ascension of the ascending node derivative.
  705.      * @return right ascension of the ascending node derivative (rad/s)
  706.      */
  707.     public T getRightAscensionOfAscendingNodeDot() {
  708.         return raanDot;
  709.     }

  710.     /** {@inheritDoc} */
  711.     @Override
  712.     public T getLv() {
  713.         return getAlphaV().add(raan);
  714.     }

  715.     /** {@inheritDoc} */
  716.     @Override
  717.     public T getLvDot() {
  718.         return getAlphaVDot().add(raanDot);
  719.     }

  720.     /** {@inheritDoc} */
  721.     @Override
  722.     public T getLE() {
  723.         return getAlphaE().add(raan);
  724.     }

  725.     /** {@inheritDoc} */
  726.     @Override
  727.     public T getLEDot() {
  728.         return getAlphaEDot().add(raanDot);
  729.     }

  730.     /** {@inheritDoc} */
  731.     @Override
  732.     public T getLM() {
  733.         return getAlphaM().add(raan);
  734.     }

  735.     /** {@inheritDoc} */
  736.     @Override
  737.     public T getLMDot() {
  738.         return getAlphaMDot().add(raanDot);
  739.     }

  740.     /** {@inheritDoc} */
  741.     @Override
  742.     public boolean hasNonKeplerianAcceleration() {
  743.         return aDot.getReal() != 0. || exDot.getReal() != 0 || iDot.getReal() != 0. || eyDot.getReal() != 0. || raanDot.getReal() != 0. ||
  744.                 FastMath.abs(cachedAlphaDot.subtract(computeKeplerianAlphaDot(cachedPositionAngleType, a, ex, ey, getMu(), cachedAlpha, cachedPositionAngleType)).getReal()) > TOLERANCE_POSITION_ANGLE_RATE;
  745.     }

  746.     /** Compute position and velocity but not acceleration.
  747.      */
  748.     private void computePVWithoutA() {

  749.         if (partialPV != null) {
  750.             // already computed
  751.             return;
  752.         }

  753.         // get equinoctial parameters
  754.         final T equEx = getEquinoctialEx();
  755.         final T equEy = getEquinoctialEy();
  756.         final T hx = getHx();
  757.         final T hy = getHy();
  758.         final T lE = getLE();
  759.         // inclination-related intermediate parameters
  760.         final T hx2   = hx.multiply(hx);
  761.         final T hy2   = hy.multiply(hy);
  762.         final T factH = (hx2.add(1).add(hy2)).reciprocal();

  763.         // reference axes defining the orbital plane
  764.         final T ux = (hx2.add(1).subtract(hy2)).multiply(factH);
  765.         final T uy =  hx.multiply(2).multiply(hy).multiply(factH);
  766.         final T uz = hy.multiply(-2).multiply(factH);

  767.         final T vx = uy;
  768.         final T vy = (hy2.subtract(hx2).add(1)).multiply(factH);
  769.         final T vz =  hx.multiply(factH).multiply(2);

  770.         // eccentricity-related intermediate parameters
  771.         final T exey = equEx.multiply(equEy);
  772.         final T ex2  = equEx.square();
  773.         final T ey2  = equEy.square();
  774.         final T e2   = ex2.add(ey2);
  775.         final T eta  = e2.negate().add(1).sqrt().add(1);
  776.         final T beta = eta.reciprocal();

  777.         // eccentric latitude argument
  778.         final FieldSinCos<T> scLe = FastMath.sinCos(lE);
  779.         final T cLe    = scLe.cos();
  780.         final T sLe    = scLe.sin();
  781.         final T exCeyS = equEx.multiply(cLe).add(equEy.multiply(sLe));
  782.         // coordinates of position and velocity in the orbital plane
  783.         final T x      = a.multiply(beta.negate().multiply(ey2).add(1).multiply(cLe).add(beta.multiply(exey).multiply(sLe)).subtract(equEx));
  784.         final T y      = a.multiply(beta.negate().multiply(ex2).add(1).multiply(sLe).add(beta.multiply(exey).multiply(cLe)).subtract(equEy));

  785.         final T factor = getOne().add(getMu()).divide(a).sqrt().divide(exCeyS.negate().add(1));
  786.         final T xdot   = factor.multiply( beta.multiply(equEy).multiply(exCeyS).subtract(sLe ));
  787.         final T ydot   = factor.multiply( cLe.subtract(beta.multiply(equEx).multiply(exCeyS)));

  788.         final FieldVector3D<T> position = new FieldVector3D<>(x.multiply(ux).add(y.multiply(vx)),
  789.                                                               x.multiply(uy).add(y.multiply(vy)),
  790.                                                               x.multiply(uz).add(y.multiply(vz)));
  791.         final FieldVector3D<T> velocity = new FieldVector3D<>(xdot.multiply(ux).add(ydot.multiply(vx)),
  792.                                                               xdot.multiply(uy).add(ydot.multiply(vy)),
  793.                                                               xdot.multiply(uz).add(ydot.multiply(vz)));

  794.         partialPV = new FieldPVCoordinates<>(position, velocity);

  795.     }


  796.     /** Initialize cached alpha with rate.
  797.      * @param alpha input alpha
  798.      * @param alphaDot rate of input alpha
  799.      * @param inputType position angle type passed as input
  800.      * @return alpha to cache with rate
  801.      * @since 12.1
  802.      */
  803.     private FieldUnivariateDerivative1<T> initializeCachedAlpha(final T alpha, final T alphaDot,
  804.                                                                 final PositionAngleType inputType) {
  805.         if (cachedPositionAngleType == inputType) {
  806.             return new FieldUnivariateDerivative1<>(alpha, alphaDot);

  807.         } else {
  808.             final FieldUnivariateDerivative1<T> exUD = new FieldUnivariateDerivative1<>(ex, exDot);
  809.             final FieldUnivariateDerivative1<T> eyUD = new FieldUnivariateDerivative1<>(ey, eyDot);
  810.             final FieldUnivariateDerivative1<T> alphaUD = new FieldUnivariateDerivative1<>(alpha, alphaDot);

  811.             switch (cachedPositionAngleType) {

  812.                 case ECCENTRIC:
  813.                     if (inputType == PositionAngleType.MEAN) {
  814.                         return FieldCircularLatitudeArgumentUtility.meanToEccentric(exUD, eyUD, alphaUD);
  815.                     } else {
  816.                         return FieldCircularLatitudeArgumentUtility.trueToEccentric(exUD, eyUD, alphaUD);
  817.                     }

  818.                 case TRUE:
  819.                     if (inputType == PositionAngleType.MEAN) {
  820.                         return FieldCircularLatitudeArgumentUtility.meanToTrue(exUD, eyUD, alphaUD);
  821.                     } else {
  822.                         return FieldCircularLatitudeArgumentUtility.eccentricToTrue(exUD, eyUD, alphaUD);
  823.                     }

  824.                 case MEAN:
  825.                     if (inputType == PositionAngleType.TRUE) {
  826.                         return FieldCircularLatitudeArgumentUtility.trueToMean(exUD, eyUD, alphaUD);
  827.                     } else {
  828.                         return FieldCircularLatitudeArgumentUtility.eccentricToMean(exUD, eyUD, alphaUD);
  829.                     }

  830.                 default:
  831.                     throw new OrekitInternalError(null);

  832.             }

  833.         }

  834.     }

  835.     /** Compute non-Keplerian part of the acceleration from first time derivatives.
  836.      * @return non-Keplerian part of the acceleration
  837.      */
  838.     private FieldVector3D<T> nonKeplerianAcceleration() {

  839.         final T[][] dCdP = MathArrays.buildArray(a.getField(), 6, 6);
  840.         getJacobianWrtParameters(PositionAngleType.MEAN, dCdP);

  841.         final T nonKeplerianMeanMotion = getAlphaMDot().subtract(getKeplerianMeanMotion());
  842.         final T nonKeplerianAx =     dCdP[3][0].multiply(aDot).
  843.                                  add(dCdP[3][1].multiply(exDot)).
  844.                                  add(dCdP[3][2].multiply(eyDot)).
  845.                                  add(dCdP[3][3].multiply(iDot)).
  846.                                  add(dCdP[3][4].multiply(raanDot)).
  847.                                  add(dCdP[3][5].multiply(nonKeplerianMeanMotion));
  848.         final T nonKeplerianAy =     dCdP[4][0].multiply(aDot).
  849.                                  add(dCdP[4][1].multiply(exDot)).
  850.                                  add(dCdP[4][2].multiply(eyDot)).
  851.                                  add(dCdP[4][3].multiply(iDot)).
  852.                                  add(dCdP[4][4].multiply(raanDot)).
  853.                                  add(dCdP[4][5].multiply(nonKeplerianMeanMotion));
  854.         final T nonKeplerianAz =     dCdP[5][0].multiply(aDot).
  855.                                  add(dCdP[5][1].multiply(exDot)).
  856.                                  add(dCdP[5][2].multiply(eyDot)).
  857.                                  add(dCdP[5][3].multiply(iDot)).
  858.                                  add(dCdP[5][4].multiply(raanDot)).
  859.                                  add(dCdP[5][5].multiply(nonKeplerianMeanMotion));

  860.         return new FieldVector3D<>(nonKeplerianAx, nonKeplerianAy, nonKeplerianAz);

  861.     }

  862.     /** {@inheritDoc} */
  863.     @Override
  864.     protected FieldVector3D<T> initPosition() {
  865.         // get equinoctial parameters
  866.         final T equEx = getEquinoctialEx();
  867.         final T equEy = getEquinoctialEy();
  868.         final T hx = getHx();
  869.         final T hy = getHy();
  870.         final T lE = getLE();
  871.         // inclination-related intermediate parameters
  872.         final T hx2   = hx.multiply(hx);
  873.         final T hy2   = hy.multiply(hy);
  874.         final T factH = (hx2.add(1).add(hy2)).reciprocal();

  875.         // reference axes defining the orbital plane
  876.         final T ux = (hx2.add(1).subtract(hy2)).multiply(factH);
  877.         final T uy =  hx.multiply(2).multiply(hy).multiply(factH);
  878.         final T uz = hy.multiply(-2).multiply(factH);

  879.         final T vx = uy;
  880.         final T vy = (hy2.subtract(hx2).add(1)).multiply(factH);
  881.         final T vz =  hx.multiply(factH).multiply(2);

  882.         // eccentricity-related intermediate parameters
  883.         final T exey = equEx.multiply(equEy);
  884.         final T ex2  = equEx.square();
  885.         final T ey2  = equEy.square();
  886.         final T e2   = ex2.add(ey2);
  887.         final T eta  = e2.negate().add(1).sqrt().add(1);
  888.         final T beta = eta.reciprocal();

  889.         // eccentric latitude argument
  890.         final FieldSinCos<T> scLe = FastMath.sinCos(lE);
  891.         final T cLe    = scLe.cos();
  892.         final T sLe    = scLe.sin();

  893.         // coordinates of position and velocity in the orbital plane
  894.         final T x      = a.multiply(beta.negate().multiply(ey2).add(1).multiply(cLe).add(beta.multiply(exey).multiply(sLe)).subtract(equEx));
  895.         final T y      = a.multiply(beta.negate().multiply(ex2).add(1).multiply(sLe).add(beta.multiply(exey).multiply(cLe)).subtract(equEy));

  896.         return new FieldVector3D<>(x.multiply(ux).add(y.multiply(vx)),
  897.                                    x.multiply(uy).add(y.multiply(vy)),
  898.                                    x.multiply(uz).add(y.multiply(vz)));

  899.     }

  900.     /** {@inheritDoc} */
  901.     @Override
  902.     protected TimeStampedFieldPVCoordinates<T> initPVCoordinates() {

  903.         // position and velocity
  904.         computePVWithoutA();

  905.         // acceleration
  906.         final T r2 = partialPV.getPosition().getNormSq();
  907.         final FieldVector3D<T> keplerianAcceleration = new FieldVector3D<>(r2.multiply(r2.sqrt()).reciprocal().multiply(getMu().negate()),
  908.                                                                            partialPV.getPosition());
  909.         final FieldVector3D<T> acceleration = hasNonKeplerianRates() ?
  910.                                               keplerianAcceleration.add(nonKeplerianAcceleration()) :
  911.                                               keplerianAcceleration;

  912.         return new TimeStampedFieldPVCoordinates<>(getDate(), partialPV.getPosition(), partialPV.getVelocity(), acceleration);

  913.     }

  914.     /** {@inheritDoc} */
  915.     @Override
  916.     public FieldCircularOrbit<T> inFrame(final Frame inertialFrame) {
  917.         final FieldPVCoordinates<T> fieldPVCoordinates;
  918.         if (hasNonKeplerianAcceleration()) {
  919.             fieldPVCoordinates = getPVCoordinates(inertialFrame);
  920.         } else {
  921.             final FieldKinematicTransform<T> transform = getFrame().getKinematicTransformTo(inertialFrame, getDate());
  922.             fieldPVCoordinates = transform.transformOnlyPV(getPVCoordinates());
  923.         }
  924.         final FieldCircularOrbit<T> fieldOrbit = new FieldCircularOrbit<>(fieldPVCoordinates, inertialFrame, getDate(), getMu());
  925.         if (fieldOrbit.getCachedPositionAngleType() == getCachedPositionAngleType()) {
  926.             return fieldOrbit;
  927.         } else {
  928.             return fieldOrbit.withCachedPositionAngleType(getCachedPositionAngleType());
  929.         }
  930.     }

  931.     /** {@inheritDoc} */
  932.     @Override
  933.     public FieldCircularOrbit<T> withCachedPositionAngleType(final PositionAngleType positionAngleType) {
  934.         return new FieldCircularOrbit<>(a, ex, ey, i, raan, getAlpha(positionAngleType), aDot, exDot, eyDot, iDot, raanDot,
  935.                 getAlphaDot(positionAngleType), positionAngleType, getFrame(), getDate(), getMu());
  936.     }

  937.     /** {@inheritDoc} */
  938.     @Override
  939.     public FieldCircularOrbit<T> shiftedBy(final double dt) {
  940.         return shiftedBy(getZero().newInstance(dt));
  941.     }

  942.     /** {@inheritDoc} */
  943.     @Override
  944.     public FieldCircularOrbit<T> shiftedBy(final T dt) {

  945.         // use Keplerian-only motion
  946.         final FieldCircularOrbit<T> keplerianShifted = new FieldCircularOrbit<>(a, ex, ey, i, raan,
  947.                                                                                 getAlphaM().add(getKeplerianMeanMotion().multiply(dt)),
  948.                                                                                 PositionAngleType.MEAN, cachedPositionAngleType, getFrame(),
  949.                                                                                 getDate().shiftedBy(dt), getMu());

  950.         if (hasNonKeplerianRates()) {

  951.             // extract non-Keplerian acceleration from first time derivatives
  952.             final FieldVector3D<T> nonKeplerianAcceleration = nonKeplerianAcceleration();

  953.             // add quadratic effect of non-Keplerian acceleration to Keplerian-only shift
  954.             keplerianShifted.computePVWithoutA();
  955.             final FieldVector3D<T> fixedP   = new FieldVector3D<>(getOne(), keplerianShifted.partialPV.getPosition(),
  956.                                                                   dt.square().multiply(0.5), nonKeplerianAcceleration);
  957.             final T   fixedR2 = fixedP.getNormSq();
  958.             final T   fixedR  = fixedR2.sqrt();
  959.             final FieldVector3D<T> fixedV  = new FieldVector3D<>(getOne(), keplerianShifted.partialPV.getVelocity(),
  960.                                                                  dt, nonKeplerianAcceleration);
  961.             final FieldVector3D<T> fixedA  = new FieldVector3D<>(fixedR2.multiply(fixedR).reciprocal().multiply(getMu().negate()),
  962.                                                                  keplerianShifted.partialPV.getPosition(),
  963.                                                                  getOne(), nonKeplerianAcceleration);

  964.             // build a new orbit, taking non-Keplerian acceleration into account
  965.             return new FieldCircularOrbit<>(new TimeStampedFieldPVCoordinates<>(keplerianShifted.getDate(),
  966.                                                                                 fixedP, fixedV, fixedA),
  967.                                             keplerianShifted.getFrame(), keplerianShifted.getMu());

  968.         } else {
  969.             // Keplerian-only motion is all we can do
  970.             return keplerianShifted;
  971.         }

  972.     }

  973.     /** {@inheritDoc} */
  974.     @Override
  975.     protected T[][] computeJacobianMeanWrtCartesian() {

  976.         final T[][] jacobian = MathArrays.buildArray(getOne().getField(), 6, 6);

  977.         // compute various intermediate parameters
  978.         computePVWithoutA();
  979.         final FieldVector3D<T> position = partialPV.getPosition();
  980.         final FieldVector3D<T> velocity = partialPV.getVelocity();

  981.         final T x          = position.getX();
  982.         final T y          = position.getY();
  983.         final T z          = position.getZ();
  984.         final T vx         = velocity.getX();
  985.         final T vy         = velocity.getY();
  986.         final T vz         = velocity.getZ();
  987.         final T pv         = FieldVector3D.dotProduct(position, velocity);
  988.         final T r2         = position.getNormSq();
  989.         final T r          = r2.sqrt();
  990.         final T v2         = velocity.getNormSq();

  991.         final T mu         = getMu();
  992.         final T oOsqrtMuA  = getOne().divide(a.multiply(mu).sqrt());
  993.         final T rOa        = r.divide(a);
  994.         final T aOr        = a.divide(r);
  995.         final T aOr2       = a.divide(r2);
  996.         final T a2         = a.square();

  997.         final T ex2        = ex.square();
  998.         final T ey2        = ey.square();
  999.         final T e2         = ex2.add(ey2);
  1000.         final T epsilon    = e2.negate().add(1.0).sqrt();
  1001.         final T beta       = epsilon.add(1).reciprocal();

  1002.         final T eCosE      = rOa.negate().add(1);
  1003.         final T eSinE      = pv.multiply(oOsqrtMuA);

  1004.         final FieldSinCos<T> scI    = FastMath.sinCos(i);
  1005.         final FieldSinCos<T> scRaan = FastMath.sinCos(raan);
  1006.         final T cosI       = scI.cos();
  1007.         final T sinI       = scI.sin();
  1008.         final T cosRaan    = scRaan.cos();
  1009.         final T sinRaan    = scRaan.sin();

  1010.         // da
  1011.         fillHalfRow(aOr.multiply(2.0).multiply(aOr2), position, jacobian[0], 0);
  1012.         fillHalfRow(a2.multiply(mu.divide(2.).reciprocal()), velocity, jacobian[0], 3);

  1013.         // differentials of the normalized momentum
  1014.         final FieldVector3D<T> danP = new FieldVector3D<>(v2, position, pv.negate(), velocity);
  1015.         final FieldVector3D<T> danV = new FieldVector3D<>(r2, velocity, pv.negate(), position);
  1016.         final T recip   = partialPV.getMomentum().getNorm().reciprocal();
  1017.         final T recip2  = recip.multiply(recip);
  1018.         final T recip2N = recip2.negate();
  1019.         final FieldVector3D<T> dwXP = new FieldVector3D<>(recip,
  1020.                                                           new FieldVector3D<>(getZero(), vz, vy.negate()),
  1021.                                                           recip2N.multiply(sinRaan).multiply(sinI),
  1022.                                                           danP);
  1023.         final FieldVector3D<T> dwYP = new FieldVector3D<>(recip,
  1024.                                                           new FieldVector3D<>(vz.negate(), getZero(), vx),
  1025.                                                           recip2.multiply(cosRaan).multiply(sinI),
  1026.                                                           danP);
  1027.         final FieldVector3D<T> dwZP = new FieldVector3D<>(recip,
  1028.                                                           new FieldVector3D<>(vy, vx.negate(), getZero()),
  1029.                                                           recip2N.multiply(cosI),
  1030.                                                           danP);
  1031.         final FieldVector3D<T> dwXV = new FieldVector3D<>(recip,
  1032.                                                           new FieldVector3D<>(getZero(), z.negate(), y),
  1033.                                                           recip2N.multiply(sinRaan).multiply(sinI),
  1034.                                                           danV);
  1035.         final FieldVector3D<T> dwYV = new FieldVector3D<>(recip,
  1036.                                                           new FieldVector3D<>(z, getZero(), x.negate()),
  1037.                                                           recip2.multiply(cosRaan).multiply(sinI),
  1038.                                                           danV);
  1039.         final FieldVector3D<T> dwZV = new FieldVector3D<>(recip,
  1040.                                                           new FieldVector3D<>(y.negate(), x, getZero()),
  1041.                                                           recip2N.multiply(cosI),
  1042.                                                           danV);

  1043.         // di
  1044.         fillHalfRow(sinRaan.multiply(cosI), dwXP, cosRaan.negate().multiply(cosI), dwYP, sinI.negate(), dwZP, jacobian[3], 0);
  1045.         fillHalfRow(sinRaan.multiply(cosI), dwXV, cosRaan.negate().multiply(cosI), dwYV, sinI.negate(), dwZV, jacobian[3], 3);

  1046.         // dRaan
  1047.         fillHalfRow(sinRaan.divide(sinI), dwYP, cosRaan.divide(sinI), dwXP, jacobian[4], 0);
  1048.         fillHalfRow(sinRaan.divide(sinI), dwYV, cosRaan.divide(sinI), dwXV, jacobian[4], 3);

  1049.         // orbital frame: (p, q, w) p along ascending node, w along momentum
  1050.         // the coordinates of the spacecraft in this frame are: (u, v, 0)
  1051.         final T u     =  x.multiply(cosRaan).add(y.multiply(sinRaan));
  1052.         final T cv    =  x.negate().multiply(sinRaan).add(y.multiply(cosRaan));
  1053.         final T v     = cv.multiply(cosI).add(z.multiply(sinI));

  1054.         // du
  1055.         final FieldVector3D<T> duP = new FieldVector3D<>(cv.multiply(cosRaan).divide(sinI), dwXP,
  1056.                                                          cv.multiply(sinRaan).divide(sinI), dwYP,
  1057.                                                          getOne(), new FieldVector3D<>(cosRaan, sinRaan, getZero()));
  1058.         final FieldVector3D<T> duV = new FieldVector3D<>(cv.multiply(cosRaan).divide(sinI), dwXV,
  1059.                                                          cv.multiply(sinRaan).divide(sinI), dwYV);

  1060.         // dv
  1061.         final FieldVector3D<T> dvP = new FieldVector3D<>(u.negate().multiply(cosRaan).multiply(cosI).divide(sinI).add(sinRaan.multiply(z)), dwXP,
  1062.                                                          u.negate().multiply(sinRaan).multiply(cosI).divide(sinI).subtract(cosRaan.multiply(z)), dwYP,
  1063.                                                          cv, dwZP,
  1064.                                                          getOne(), new FieldVector3D<>(sinRaan.negate().multiply(cosI), cosRaan.multiply(cosI), sinI));
  1065.         final FieldVector3D<T> dvV = new FieldVector3D<>(u.negate().multiply(cosRaan).multiply(cosI).divide(sinI).add(sinRaan.multiply(z)), dwXV,
  1066.                                                          u.negate().multiply(sinRaan).multiply(cosI).divide(sinI).subtract(cosRaan.multiply(z)), dwYV,
  1067.                                                          cv, dwZV);

  1068.         final FieldVector3D<T> dc1P = new FieldVector3D<>(aOr2.multiply(eSinE.multiply(eSinE).multiply(2).add(1).subtract(eCosE)).divide(r2), position,
  1069.                                                           aOr2.multiply(-2).multiply(eSinE).multiply(oOsqrtMuA), velocity);
  1070.         final FieldVector3D<T> dc1V = new FieldVector3D<>(aOr2.multiply(-2).multiply(eSinE).multiply(oOsqrtMuA), position,
  1071.                                                           getZero().newInstance(2).divide(mu), velocity);
  1072.         final FieldVector3D<T> dc2P = new FieldVector3D<>(aOr2.multiply(eSinE).multiply(eSinE.multiply(eSinE).subtract(e2.negate().add(1))).divide(r2.multiply(epsilon)), position,
  1073.                                                           aOr2.multiply(e2.negate().add(1).subtract(eSinE.multiply(eSinE))).multiply(oOsqrtMuA).divide(epsilon), velocity);
  1074.         final FieldVector3D<T> dc2V = new FieldVector3D<>(aOr2.multiply(e2.negate().add(1).subtract(eSinE.multiply(eSinE))).multiply(oOsqrtMuA).divide(epsilon), position,
  1075.                                                           eSinE.divide(epsilon.multiply(mu)), velocity);

  1076.         final T cof1   = aOr2.multiply(eCosE.subtract(e2));
  1077.         final T cof2   = aOr2.multiply(epsilon).multiply(eSinE);
  1078.         final FieldVector3D<T> dexP = new FieldVector3D<>(u, dc1P,  v, dc2P, cof1, duP,  cof2, dvP);
  1079.         final FieldVector3D<T> dexV = new FieldVector3D<>(u, dc1V,  v, dc2V, cof1, duV,  cof2, dvV);
  1080.         final FieldVector3D<T> deyP = new FieldVector3D<>(v, dc1P, u.negate(), dc2P, cof1, dvP, cof2.negate(), duP);
  1081.         final FieldVector3D<T> deyV = new FieldVector3D<>(v, dc1V, u.negate(), dc2V, cof1, dvV, cof2.negate(), duV);
  1082.         fillHalfRow(getOne(), dexP, jacobian[1], 0);
  1083.         fillHalfRow(getOne(), dexV, jacobian[1], 3);
  1084.         fillHalfRow(getOne(), deyP, jacobian[2], 0);
  1085.         fillHalfRow(getOne(), deyV, jacobian[2], 3);

  1086.         final T cle = u.divide(a).add(ex).subtract(eSinE.multiply(beta).multiply(ey));
  1087.         final T sle = v.divide(a).add(ey).add(eSinE.multiply(beta).multiply(ex));
  1088.         final T m1  = beta.multiply(eCosE);
  1089.         final T m2  = m1.multiply(eCosE).negate().add(1);
  1090.         final T m3  = (u.multiply(ey).subtract(v.multiply(ex))).add(eSinE.multiply(beta).multiply(u.multiply(ex).add(v.multiply(ey))));
  1091.         final T m4  = sle.negate().add(cle.multiply(eSinE).multiply(beta));
  1092.         final T m5  = cle.add(sle.multiply(eSinE).multiply(beta));
  1093.         final T kk = m3.multiply(2).divide(r).add(aOr.multiply(eSinE)).add(m1.multiply(eSinE).multiply(m1.add(1).subtract(aOr.add(1).multiply(m2))).divide(epsilon)).divide(r2);
  1094.         final T jj = (m1.multiply(m2).divide(epsilon).subtract(1)).multiply(oOsqrtMuA);
  1095.         fillHalfRow(kk, position,
  1096.                     jj, velocity,
  1097.                     m4, dexP,
  1098.                     m5, deyP,
  1099.                     sle.negate().divide(a), duP,
  1100.                     cle.divide(a), dvP,
  1101.                     jacobian[5], 0);
  1102.         final T ll = (m1.multiply(m2).divide(epsilon ).subtract(1)).multiply(oOsqrtMuA);
  1103.         final T mm = m3.multiply(2).add(eSinE.multiply(a)).add(m1.multiply(eSinE).multiply(r).multiply(eCosE.multiply(beta).multiply(2).subtract(aOr.multiply(m2))).divide(epsilon)).divide(mu);

  1104.         fillHalfRow(ll, position,
  1105.                     mm, velocity,
  1106.                     m4, dexV,
  1107.                     m5, deyV,
  1108.                     sle.negate().divide(a), duV,
  1109.                     cle.divide(a), dvV,
  1110.                     jacobian[5], 3);
  1111.         return jacobian;

  1112.     }

  1113.     /** {@inheritDoc} */
  1114.     @Override
  1115.     protected T[][] computeJacobianEccentricWrtCartesian() {

  1116.         // start by computing the Jacobian with mean angle
  1117.         final T[][] jacobian = computeJacobianMeanWrtCartesian();

  1118.         // Differentiating the Kepler equation aM = aE - ex sin aE + ey cos aE leads to:
  1119.         // daM = (1 - ex cos aE - ey sin aE) dE - sin aE dex + cos aE dey
  1120.         // which is inverted and rewritten as:
  1121.         // daE = a/r daM + sin aE a/r dex - cos aE a/r dey
  1122.         final T alphaE            = getAlphaE();
  1123.         final FieldSinCos<T> scAe = FastMath.sinCos(alphaE);
  1124.         final T cosAe             = scAe.cos();
  1125.         final T sinAe             = scAe.sin();
  1126.         final T aOr               = getOne().divide(getOne().subtract(ex.multiply(cosAe)).subtract(ey.multiply(sinAe)));

  1127.         // update longitude row
  1128.         final T[] rowEx = jacobian[1];
  1129.         final T[] rowEy = jacobian[2];
  1130.         final T[] rowL  = jacobian[5];
  1131.         for (int j = 0; j < 6; ++j) {
  1132.          // rowL[j] = aOr * (      rowL[j] +   sinAe *        rowEx[j]   -         cosAe *        rowEy[j]);
  1133.             rowL[j] = aOr.multiply(rowL[j].add(sinAe.multiply(rowEx[j])).subtract( cosAe.multiply(rowEy[j])));
  1134.         }
  1135.         jacobian[5] = rowL;
  1136.         return jacobian;

  1137.     }
  1138.     /** {@inheritDoc} */
  1139.     @Override
  1140.     protected T[][] computeJacobianTrueWrtCartesian() {

  1141.         // start by computing the Jacobian with eccentric angle
  1142.         final T[][] jacobian = computeJacobianEccentricWrtCartesian();
  1143.         // Differentiating the eccentric latitude equation
  1144.         // tan((aV - aE)/2) = [ex sin aE - ey cos aE] / [sqrt(1-ex^2-ey^2) + 1 - ex cos aE - ey sin aE]
  1145.         // leads to
  1146.         // cT (daV - daE) = cE daE + cX dex + cY dey
  1147.         // with
  1148.         // cT = [d^2 + (ex sin aE - ey cos aE)^2] / 2
  1149.         // d  = 1 + sqrt(1-ex^2-ey^2) - ex cos aE - ey sin aE
  1150.         // cE = (ex cos aE + ey sin aE) (sqrt(1-ex^2-ey^2) + 1) - ex^2 - ey^2
  1151.         // cX =  sin aE (sqrt(1-ex^2-ey^2) + 1) - ey + ex (ex sin aE - ey cos aE) / sqrt(1-ex^2-ey^2)
  1152.         // cY = -cos aE (sqrt(1-ex^2-ey^2) + 1) + ex + ey (ex sin aE - ey cos aE) / sqrt(1-ex^2-ey^2)
  1153.         // which can be solved to find the differential of the true latitude
  1154.         // daV = (cT + cE) / cT daE + cX / cT deX + cY / cT deX
  1155.         final T alphaE            = getAlphaE();
  1156.         final FieldSinCos<T> scAe = FastMath.sinCos(alphaE);
  1157.         final T cosAe             = scAe.cos();
  1158.         final T sinAe             = scAe.sin();
  1159.         final T eSinE             = ex.multiply(sinAe).subtract(ey.multiply(cosAe));
  1160.         final T ecosE             = ex.multiply(cosAe).add(ey.multiply(sinAe));
  1161.         final T e2                = ex.multiply(ex).add(ey.multiply(ey));
  1162.         final T epsilon           = (getOne().subtract(e2)).sqrt();
  1163.         final T onePeps           = getOne().add(epsilon);
  1164.         final T d                 = onePeps.subtract(ecosE);
  1165.         final T cT                = (d.multiply(d).add(eSinE.multiply(eSinE))).divide(2);
  1166.         final T cE                = ecosE.multiply(onePeps).subtract(e2);
  1167.         final T cX                = ex.multiply(eSinE).divide(epsilon).subtract(ey).add(sinAe.multiply(onePeps));
  1168.         final T cY                = ey.multiply(eSinE).divide(epsilon).add(ex).subtract(cosAe.multiply(onePeps));
  1169.         final T factorLe          = (cT.add(cE)).divide(cT);
  1170.         final T factorEx          = cX.divide(cT);
  1171.         final T factorEy          = cY.divide(cT);

  1172.         // update latitude row
  1173.         final T[] rowEx = jacobian[1];
  1174.         final T[] rowEy = jacobian[2];
  1175.         final T[] rowA = jacobian[5];
  1176.         for (int j = 0; j < 6; ++j) {
  1177.             rowA[j] = factorLe.multiply(rowA[j]).add(factorEx.multiply(rowEx[j])).add(factorEy.multiply(rowEy[j]));
  1178.         }
  1179.         return jacobian;

  1180.     }

  1181.     /** {@inheritDoc} */
  1182.     @Override
  1183.     public void addKeplerContribution(final PositionAngleType type, final T gm, final T[] pDot) {
  1184.         pDot[5] = pDot[5].add(computeKeplerianAlphaDot(type, a, ex, ey, gm, cachedAlpha, cachedPositionAngleType));
  1185.     }

  1186.     /**
  1187.      * Compute rate of argument of latitude.
  1188.      * @param type position angle type of rate
  1189.      * @param a semi major axis
  1190.      * @param ex ex
  1191.      * @param ey ey
  1192.      * @param mu mu
  1193.      * @param alpha argument of latitude
  1194.      * @param cachedType position angle type of passed alpha
  1195.      * @param <T> field type
  1196.      * @return first-order time derivative for alpha
  1197.      * @since 12.2
  1198.      */
  1199.     private static <T extends CalculusFieldElement<T>> T computeKeplerianAlphaDot(final PositionAngleType type, final T a,
  1200.                                                                                   final T ex, final T ey, final T mu,
  1201.                                                                                   final T alpha, final PositionAngleType cachedType) {
  1202.         final T n = a.reciprocal().multiply(mu).sqrt().divide(a);
  1203.         if (type == PositionAngleType.MEAN) {
  1204.             return n;
  1205.         }
  1206.         final FieldSinCos<T> sc;
  1207.         final T ksi;
  1208.         if (type == PositionAngleType.ECCENTRIC) {
  1209.             sc = FastMath.sinCos(FieldCircularLatitudeArgumentUtility.convertAlpha(cachedType, alpha, ex, ey, type));
  1210.             ksi  = ((ex.multiply(sc.cos())).add(ey.multiply(sc.sin()))).negate().add(1).reciprocal();
  1211.             return n.multiply(ksi);
  1212.         } else {  // TRUE
  1213.             sc = FastMath.sinCos(FieldCircularLatitudeArgumentUtility.convertAlpha(cachedType, alpha, ex, ey, type));
  1214.             final T one = n.getField().getOne();
  1215.             final T oMe2  = one.subtract(ex.square()).subtract(ey.square());
  1216.             ksi   = one.add(ex.multiply(sc.cos())).add(ey.multiply(sc.sin()));
  1217.             return n.multiply(ksi.square()).divide(oMe2.multiply(oMe2.sqrt()));
  1218.         }
  1219.     }

  1220.     /**  Returns a string representation of this Orbit object.
  1221.      * @return a string representation of this object
  1222.      */
  1223.     public String toString() {
  1224.         return new StringBuilder().append("circular parameters: ").append('{').
  1225.                                   append("a: ").append(a.getReal()).
  1226.                                   append(", ex: ").append(ex.getReal()).append(", ey: ").append(ey.getReal()).
  1227.                                   append(", i: ").append(FastMath.toDegrees(i.getReal())).
  1228.                                   append(", raan: ").append(FastMath.toDegrees(raan.getReal())).
  1229.                                   append(", alphaV: ").append(FastMath.toDegrees(getAlphaV().getReal())).
  1230.                                   append(";}").toString();
  1231.     }

  1232.     /** {@inheritDoc} */
  1233.     @Override
  1234.     public PositionAngleType getCachedPositionAngleType() {
  1235.         return cachedPositionAngleType;
  1236.     }

  1237.     /** {@inheritDoc} */
  1238.     @Override
  1239.     public boolean hasNonKeplerianRates() {
  1240.         return hasNonKeplerianAcceleration();
  1241.     }

  1242.     /** {@inheritDoc} */
  1243.     @Override
  1244.     public FieldCircularOrbit<T> withKeplerianRates() {
  1245.         return new FieldCircularOrbit<>(getA(), getCircularEx(), getCircularEy(),
  1246.                 getI(), getRightAscensionOfAscendingNode(), cachedAlpha,
  1247.                 cachedPositionAngleType, getFrame(), getDate(), getMu());
  1248.     }

  1249.     /** {@inheritDoc} */
  1250.     @Override
  1251.     public CircularOrbit toOrbit() {
  1252.         final double cachedPositionAngle = cachedAlpha.getReal();
  1253.         return new CircularOrbit(a.getReal(), ex.getReal(), ey.getReal(),
  1254.                                  i.getReal(), raan.getReal(), cachedPositionAngle,
  1255.                                  aDot.getReal(), exDot.getReal(), eyDot.getReal(),
  1256.                                  iDot.getReal(), raanDot.getReal(), cachedAlphaDot.getReal(),
  1257.                                  cachedPositionAngleType, getFrame(),
  1258.                                  getDate().toAbsoluteDate(), getMu().getReal());
  1259.     }


  1260. }