GTODProvider.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.frames;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.geometry.euclidean.threed.FieldRotation;
  20. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  21. import org.hipparchus.geometry.euclidean.threed.Rotation;
  22. import org.hipparchus.geometry.euclidean.threed.RotationConvention;
  23. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  24. import org.orekit.time.AbsoluteDate;
  25. import org.orekit.time.FieldAbsoluteDate;
  26. import org.orekit.time.TimeScalarFunction;
  27. import org.orekit.time.TimeScale;
  28. import org.orekit.time.TimeScales;
  29. import org.orekit.utils.Constants;
  30. import org.orekit.utils.IERSConventions;

  31. /** Greenwich True Of Date Frame, also known as True of Date Rotating frame (TDR)
  32.  * or Greenwich Rotating Coordinate frame (GCR).
  33.  * <p> This frame handles the sidereal time according to IAU-82 model.</p>
  34.  * <p> Its parent frame is the {@link TODProvider}.</p>
  35.  * <p> The pole motion is not applied here.</p>
  36.  * @author Pascal Parraud
  37.  * @author Thierry Ceolin
  38.  */
  39. public class GTODProvider implements EOPBasedTransformProvider {

  40.     /** Angular velocity of the Earth, in rad/s. */
  41.     private static final double AVE = 7.292115146706979e-5;

  42.     /** Conventions. */
  43.     private final IERSConventions conventions;

  44.     /** EOP history. */
  45.     private final EOPHistory eopHistory;

  46.     /** GAST function. */
  47.     private final transient TimeScalarFunction gastFunction;

  48.     /** Simple constructor.
  49.      * @param conventions IERS conventions to use
  50.      * @param eopHistory EOP history (may be null)
  51.      * @param timeScales  set of time scales to use.
  52.      * @since 10.1
  53.      */
  54.     protected GTODProvider(final IERSConventions conventions,
  55.                            final EOPHistory eopHistory,
  56.                            final TimeScales timeScales) {
  57.         final TimeScale ut1 = eopHistory == null ?
  58.                 timeScales.getUTC() : // UT1 wihthout EOP is UTC
  59.                 timeScales.getUT1(eopHistory.getConventions(), eopHistory.isSimpleEop());
  60.         this.conventions   = conventions;
  61.         this.eopHistory    = eopHistory;
  62.         this.gastFunction  = conventions.getGASTFunction(ut1, eopHistory, timeScales);
  63.     }

  64.     /**
  65.      * Private constructor.
  66.      *
  67.      * @param conventions  IERS conventions to use
  68.      * @param eopHistory   EOP history (may be null)
  69.      * @param gastFunction GAST function
  70.      */
  71.     private GTODProvider(final IERSConventions conventions,
  72.                          final EOPHistory eopHistory,
  73.                          final TimeScalarFunction gastFunction) {
  74.         this.conventions = conventions;
  75.         this.eopHistory = eopHistory;
  76.         this.gastFunction = gastFunction;
  77.     }

  78.     /** {@inheritDoc} */
  79.     @Override
  80.     public EOPHistory getEOPHistory() {
  81.         return eopHistory;
  82.     }

  83.     /** {@inheritDoc} */
  84.     @Override
  85.     public GTODProvider getNonInterpolatingProvider() {
  86.         return new GTODProvider(conventions, eopHistory.getEOPHistoryWithoutCachedTidalCorrection(),
  87.                 gastFunction);
  88.     }

  89.     /** {@inheritDoc} */
  90.     @Override
  91.     public Transform getTransform(final AbsoluteDate date) {
  92.         return new Transform(date, getRotation(date), getRotationRate(date));
  93.     }

  94.     /** {@inheritDoc} */
  95.     @Override
  96.     public KinematicTransform getKinematicTransform(final AbsoluteDate date) {
  97.         return KinematicTransform.of(date, getRotation(date), getRotationRate(date));
  98.     }

  99.     /** {@inheritDoc} */
  100.     @Override
  101.     public StaticTransform getStaticTransform(final AbsoluteDate date) {
  102.         return StaticTransform.of(date, getRotation(date));
  103.     }

  104.     /** Form rotation to parent TOD.
  105.      * @param date transform date
  106.      * @return rotation to parent at date
  107.      * @since 12.1
  108.      */
  109.     private Rotation getRotation(final AbsoluteDate date) {
  110.         // compute Greenwich apparent sidereal time, in radians
  111.         final double gast = gastFunction.value(date);

  112.         // set up the transform from parent TOD
  113.         return new Rotation(Vector3D.PLUS_K, gast, RotationConvention.FRAME_TRANSFORM);
  114.     }

  115.     /** Form rotation rate w.r.t. parent TOD.
  116.      * @param date transform date
  117.      * @return rotation rate at date
  118.      * @since 12.1
  119.      */
  120.     private Vector3D getRotationRate(final AbsoluteDate date) {
  121.         // compute true angular rotation of Earth, in rad/s
  122.         final double lod = (eopHistory == null) ? 0.0 : eopHistory.getLOD(date);
  123.         final double omp = AVE * (1 - lod / Constants.JULIAN_DAY);
  124.         return new Vector3D(omp, Vector3D.PLUS_K);
  125.     }

  126.     /** {@inheritDoc} */
  127.     @Override
  128.     public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
  129.         return new FieldTransform<>(date, getRotation(date), getRotationRate(date));
  130.     }

  131.     /** {@inheritDoc} */
  132.     @Override
  133.     public <T extends CalculusFieldElement<T>> FieldKinematicTransform<T> getKinematicTransform(final FieldAbsoluteDate<T> date) {
  134.         return FieldKinematicTransform.of(date, getRotation(date), getRotationRate(date));
  135.     }

  136.     /** {@inheritDoc} */
  137.     @Override
  138.     public <T extends CalculusFieldElement<T>> FieldStaticTransform<T> getStaticTransform(final FieldAbsoluteDate<T> date) {
  139.         return FieldStaticTransform.of(date, getRotation(date));
  140.     }

  141.     /** Form rotation to parent TOD.
  142.      * @param <T> type of the elements
  143.      * @param date transform date
  144.      * @return rotation to parent at date
  145.      * @since 12.1
  146.      */
  147.     private <T extends CalculusFieldElement<T>> FieldRotation<T> getRotation(final FieldAbsoluteDate<T> date) {
  148.         // compute Greenwich apparent sidereal time, in radians
  149.         final T gast = gastFunction.value(date);

  150.         // set up the transform from parent TOD
  151.         return new FieldRotation<>(FieldVector3D.getPlusK(date.getField()), gast, RotationConvention.FRAME_TRANSFORM);
  152.     }

  153.     /** Form rotation rate w.r.t. parent TOD.
  154.      * @param <T> type of the elements
  155.      * @param date transform date
  156.      * @return rotation rate at date
  157.      * @since 12.1
  158.      */
  159.     private <T extends CalculusFieldElement<T>> FieldVector3D<T> getRotationRate(final FieldAbsoluteDate<T> date) {
  160.         // compute true angular rotation of Earth, in rad/s
  161.         final T lod = (eopHistory == null) ? date.getField().getZero() : eopHistory.getLOD(date);
  162.         final T omp = lod.multiply(-1.0 / Constants.JULIAN_DAY).add(1).multiply(AVE);
  163.         return new FieldVector3D<>(date.getField().getZero(),
  164.                 date.getField().getZero(),
  165.                 date.getField().getZero().add(omp));
  166.     }

  167. }