TIRFProvider.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.hipparchus.util.MathUtils;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.time.FieldAbsoluteDate;
  27. import org.orekit.time.TimeScalarFunction;
  28. import org.orekit.time.TimeScale;
  29. import org.orekit.utils.Constants;

  30. /** Terrestrial Intermediate Reference Frame.
  31.  * <p> The pole motion is not considered : Pseudo Earth Fixed Frame. It handles
  32.  * the earth rotation angle, its parent frame is the {@link CIRFProvider}</p>
  33.  */
  34. class TIRFProvider implements EOPBasedTransformProvider {

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

  37.     /** EOP history. */
  38.     private final EOPHistory eopHistory;

  39.     /** UT1 time scale. */
  40.     private final transient TimeScale ut1;

  41.     /** ERA function. */
  42.     private final transient TimeScalarFunction era;

  43.     /** Simple constructor.
  44.      * @param eopHistory EOP history
  45.      * @param ut1 the UT1 time scale.
  46.      */
  47.     protected TIRFProvider(final EOPHistory eopHistory, final TimeScale ut1) {

  48.         this.ut1        = ut1;
  49.         this.eopHistory = eopHistory;
  50.         this.era        = eopHistory.getConventions().getEarthOrientationAngleFunction(
  51.                 ut1,
  52.                 eopHistory.getTimeScales().getTAI());

  53.     }

  54.     /** {@inheritDoc} */
  55.     @Override
  56.     public EOPHistory getEOPHistory() {
  57.         return eopHistory;
  58.     }

  59.     /** {@inheritDoc} */
  60.     @Override
  61.     public TIRFProvider getNonInterpolatingProvider() {
  62.         return new TIRFProvider(eopHistory.getEOPHistoryWithoutCachedTidalCorrection(), ut1);
  63.     }

  64.     /** {@inheritDoc} */
  65.     @Override
  66.     public Transform getTransform(final AbsoluteDate date) {
  67.         return new Transform(date, getRotation(date), getRotationRate(date));
  68.     }

  69.     /** {@inheritDoc} */
  70.     @Override
  71.     public KinematicTransform getKinematicTransform(final AbsoluteDate date) {
  72.         return KinematicTransform.of(date, getRotation(date), getRotationRate(date));
  73.     }

  74.     /** {@inheritDoc} */
  75.     @Override
  76.     public StaticTransform getStaticTransform(final AbsoluteDate date) {
  77.         return StaticTransform.of(date, getRotation(date));
  78.     }

  79.     /** Form rotation to parent CIRF.
  80.      * @param date transform date
  81.      * @return rotation to parent at date
  82.      * @since 12.1
  83.      */
  84.     private Rotation getRotation(final AbsoluteDate date) {
  85.         // compute proper rotation
  86.         final double correctedERA = era.value(date);
  87.         // set up the transform from parent CIRF
  88.         return new Rotation(Vector3D.PLUS_K, correctedERA, RotationConvention.FRAME_TRANSFORM);
  89.     }

  90.     /** Form rotation rate w.r.t. parent CIRF.
  91.      * @param date transform date
  92.      * @return rotation rate at date
  93.      * @since 12.1
  94.      */
  95.     private Vector3D getRotationRate(final AbsoluteDate date) {
  96.         // compute true angular rotation of Earth, in rad/s
  97.         final double lod = (eopHistory == null) ? 0.0 : eopHistory.getLOD(date);
  98.         final double omp = AVE * (1 - lod / Constants.JULIAN_DAY);
  99.         return new Vector3D(omp, Vector3D.PLUS_K);
  100.     }

  101.     /** {@inheritDoc} */
  102.     @Override
  103.     public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
  104.         return new FieldTransform<>(date, getRotation(date), getRotationRate(date));
  105.     }

  106.     /** {@inheritDoc} */
  107.     @Override
  108.     public <T extends CalculusFieldElement<T>> FieldKinematicTransform<T> getKinematicTransform(final FieldAbsoluteDate<T> date) {
  109.         return FieldKinematicTransform.of(date, getRotation(date), getRotationRate(date));
  110.     }

  111.     /** {@inheritDoc} */
  112.     @Override
  113.     public <T extends CalculusFieldElement<T>> FieldStaticTransform<T> getStaticTransform(final FieldAbsoluteDate<T> date) {
  114.         return FieldStaticTransform.of(date, getRotation(date));
  115.     }

  116.     /** Form rotation to parent CIRF.
  117.      * @param <T> type of the elements
  118.      * @param date transform date
  119.      * @return rotation to parent at date
  120.      * @since 12.1
  121.      */
  122.     private <T extends CalculusFieldElement<T>> FieldRotation<T> getRotation(final FieldAbsoluteDate<T> date) {
  123.         // compute proper rotation
  124.         final T correctedERA = era.value(date);

  125.         // set up the transform from parent CIRF
  126.         return new FieldRotation<>(
  127.                 FieldVector3D.getPlusK(date.getField()),
  128.                 correctedERA,
  129.                 RotationConvention.FRAME_TRANSFORM);
  130.     }

  131.     /** Form rotation rate w.r.t. parent CIRF.
  132.      * @param <T> type of the elements
  133.      * @param date transform date
  134.      * @return rotation rate at date
  135.      * @since 12.1
  136.      */
  137.     private <T extends CalculusFieldElement<T>> FieldVector3D<T> getRotationRate(final FieldAbsoluteDate<T> date) {
  138.         // compute true angular rotation of Earth, in rad/s
  139.         final T lod = (eopHistory == null) ? date.getField().getZero() : eopHistory.getLOD(date);
  140.         final T omp = lod.divide(Constants.JULIAN_DAY).subtract(1).multiply(-AVE);
  141.         return new FieldVector3D<>(omp, Vector3D.PLUS_K);
  142.     }

  143.     /** Get the Earth Rotation Angle at the current date.
  144.      * @param  date the date
  145.      * @return Earth Rotation Angle at the current date in radians
  146.      */
  147.     public double getEarthRotationAngle(final AbsoluteDate date) {
  148.         return MathUtils.normalizeAngle(era.value(date), 0);
  149.     }

  150. }