HelmertTransformation.java

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

  18. import java.util.Optional;
  19. import java.util.stream.Stream;

  20. import org.hipparchus.CalculusFieldElement;
  21. import org.hipparchus.geometry.euclidean.threed.FieldRotation;
  22. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  23. import org.hipparchus.geometry.euclidean.threed.Rotation;
  24. import org.hipparchus.geometry.euclidean.threed.RotationConvention;
  25. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  26. import org.hipparchus.util.Precision;
  27. import org.orekit.annotation.DefaultDataContext;
  28. import org.orekit.data.DataContext;
  29. import org.orekit.time.AbsoluteDate;
  30. import org.orekit.time.DateTimeComponents;
  31. import org.orekit.time.FieldAbsoluteDate;
  32. import org.orekit.time.TimeScale;
  33. import org.orekit.utils.Constants;
  34. import org.orekit.utils.FieldPVCoordinates;
  35. import org.orekit.utils.PVCoordinates;


  36. /** Transformation class for geodetic systems.
  37.  *
  38.  * <p>The Helmert transformation is mainly used to convert between various
  39.  * realizations of geodetic frames, for example in the ITRF family.</p>
  40.  *
  41.  * <p>The original Helmert transformation is a 14 parameters transform that
  42.  * includes translation, velocity, rotation, rotation rate and scale factor.
  43.  * The scale factor is useful for coordinates near Earth surface, but it
  44.  * cannot be extended to outer space as it would correspond to a non-unitary
  45.  * transform. Therefore, the scale factor is <em>not</em> used here.
  46.  *
  47.  * <p>Instances of this class are guaranteed to be immutable.</p>
  48.  *
  49.  * @author Luc Maisonobe
  50.  * @since 5.1
  51.  */
  52. public class HelmertTransformation implements TransformProvider {

  53.     /** serializable UID. */
  54.     private static final long serialVersionUID = 20220419L;

  55.     /** Enumerate for predefined Helmert transformations. */
  56.     public enum Predefined {

  57.         // see https://itrf.ign.fr/docs/solutions/itrf2020/Transfo-ITRF2020_TRFs.txt
  58.         // SOLUTION         Tx       Ty       Tz        D        Rx        Ry        Rz      EPOCH
  59.         // UNITS----------> mm       mm       mm       ppb       .001"     .001"     .001"
  60.         //                  .        .        .         .        .         .         .
  61.         //        RATES     Tx       Ty       Tz        D        Rx        Ry        Rz
  62.         // UNITS----------> mm/y     mm/y     mm/y     ppb/y    .001"/y   .001"/y   .001"/y
  63.         // -----------------------------------------------------------------------------------------
  64.         //   ITRF2014       -1.4     -0.9      1.4     -0.42      0.00      0.00      0.00    2015.0
  65.         //        rates      0.0     -0.1      0.2      0.00      0.00      0.00      0.00
  66.         //   ITRF2008        0.2      1.0      3.3     -0.29      0.00      0.00      0.00    2015.0
  67.         //        rates      0.0     -0.1      0.1      0.03      0.00      0.00      0.00
  68.         //   ITRF2005        2.7      0.1     -1.4      0.65      0.00      0.00      0.00    2015.0
  69.         //        rates      0.3     -0.1      0.1      0.03      0.00      0.00      0.00
  70.         //   ITRF2000       -0.2      0.8    -34.2      2.25      0.00      0.00      0.00    2015.0
  71.         //        rates      0.1      0.0     -1.7      0.11      0.00      0.00      0.00
  72.         //   ITRF97          6.5     -3.9    -77.9      3.98      0.00      0.00      0.36    2015.0
  73.         //        rates      0.1     -0.6     -3.1      0.12      0.00      0.00      0.02
  74.         //   ITRF96          6.5     -3.9    -77.9      3.98      0.00      0.00      0.36    2015.0
  75.         //        rates      0.1     -0.6     -3.1      0.12      0.00      0.00      0.02
  76.         //   ITRF94          6.5     -3.9    -77.9      3.98      0.00      0.00      0.36    2015.0
  77.         //        rates      0.1     -0.6     -3.1      0.12      0.00      0.00      0.02
  78.         //   ITRF93        -65.8      1.9    -71.3      4.47     -3.36     -4.33      0.75    2015.0
  79.         //        rates     -2.8     -0.2     -2.3      0.12     -0.11     -0.19      0.07
  80.         //   ITRF92         14.5     -1.9    -85.9      3.27      0.00      0.00      0.36    2015.0
  81.         //        rates      0.1     -0.6     -3.1      0.12      0.00      0.00      0.02
  82.         //   ITRF91         26.5     12.1    -91.9      4.67      0.00      0.00      0.36    2015.0
  83.         //        rates      0.1     -0.6     -3.1      0.12      0.00      0.00      0.02
  84.         //   ITRF90         24.5      8.1   -107.9      4.97      0.00      0.00      0.36    2015.0
  85.         //        rates      0.1     -0.6     -3.1      0.12      0.00      0.00      0.02
  86.         //   ITRF89         29.5     32.1   -145.9      8.37      0.00      0.00      0.36    2015.0
  87.         //        rates      0.1     -0.6     -3.1      0.12      0.00      0.00      0.02
  88.         //   ITRF88         24.5     -3.9   -169.9     11.47      0.10      0.00      0.36    2015.0
  89.         //        rates      0.1     -0.6     -3.1      0.12      0.00      0.00      0.02
  90.         // _________________________________________________________________________________________

  91.         /** Transformation from ITRF 2020 To ITRF 2014. */
  92.         ITRF_2020_TO_ITRF_2014(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_2014, 2015,
  93.                                -1.4, -0.9,   1.4,  0.00,  0.00,  0.00,
  94.                                 0.0, -0.1,   0.2,  0.00,  0.00,  0.00),

  95.         /** Transformation from ITRF 2020 To ITRF 2008. */
  96.         ITRF_2020_TO_ITRF_2008(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_2008, 2015,
  97.                                0.2,  1.0,   3.3,  0.00,  0.00,  0.00,
  98.                                0.0, -0.1,   0.1,  0.00,  0.00,  0.00),

  99.         /** Transformation from ITRF 2020 To ITRF 2005. */
  100.         ITRF_2020_TO_ITRF_2005(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_2005, 2015,
  101.                                2.7,  0.1,  -1.4,  0.00,  0.00,  0.00,
  102.                                0.3, -0.1,   0.1,  0.00,  0.00,  0.00),

  103.         /** Transformation from ITRF 2020 To ITRF 2000. */
  104.         ITRF_2020_TO_ITRF_2000(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_2000, 2015,
  105.                                -0.2,  0.8, -34.2,  0.00,  0.00,  0.00,
  106.                                 0.1,  0.0,  -1.7,  0.00,  0.00,  0.00),

  107.         /** Transformation from ITRF 2020 To ITRF 97. */
  108.         ITRF_2020_TO_ITRF_1997(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_1997, 2015,
  109.                                6.5, -3.9, -77.9,  0.00,  0.00,  0.36,
  110.                                0.1, -0.6,  -3.1,  0.00,  0.00,  0.02),

  111.         /** Transformation from ITRF 2020 To ITRF 96. */
  112.         ITRF_2020_TO_ITRF_1996(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_1996, 2015,
  113.                                6.5, -3.9, -77.9,  0.00,  0.00,  0.36,
  114.                                0.1, -0.6,  -3.1,  0.00,  0.00,  0.02),

  115.         /** Transformation from ITRF 2020 To ITRF 94. */
  116.         ITRF_2020_TO_ITRF_1994(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_1994, 2015,
  117.                                6.5, -3.9, -77.9,  0.00,  0.00,  0.36,
  118.                                0.1, -0.6,  -3.1,  0.00,  0.00,  0.02),

  119.         /** Transformation from ITRF 2020 To ITRF 93. */
  120.         ITRF_2020_TO_ITRF_1993(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_1993, 2015,
  121.                                -65.8,  1.9, -71.3, -3.36, -4.33,  0.75,
  122.                                 -2.8, -0.2,  -2.3, -0.11, -0.19,  0.07),

  123.         /** Transformation from ITRF 2020 To ITRF 92. */
  124.         ITRF_2020_TO_ITRF_1992(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_1992, 2015,
  125.                                14.5, -1.9, -85.9,  0.00,  0.00,  0.36,
  126.                                 0.1, -0.6,  -3.1,  0.00,  0.00,  0.02),

  127.         /** Transformation from ITRF 2020 To ITRF 91. */
  128.         ITRF_2020_TO_ITRF_1991(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_1991, 2015,
  129.                                26.5, 12.1, -91.9,  0.00,  0.00,  0.36,
  130.                                 0.1, -0.6,  -3.1,  0.00,  0.00,  0.02),

  131.         /** Transformation from ITRF 2020 To ITRF 90. */
  132.         ITRF_2020_TO_ITRF_1990(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_1990, 2015,
  133.                                24.5,  8.1, -107.9,  0.00,  0.00,  0.36,
  134.                                 0.1, -0.6,   -3.1,  0.00,  0.00,  0.02),

  135.         /** Transformation from ITRF 2020 To ITRF 89. */
  136.         ITRF_2020_TO_ITRF_1989(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_1989, 2015,
  137.                                29.5, 32.1, -145.9,  0.00,  0.00,  0.36,
  138.                                 0.1, -0.6,   -3.1,  0.00,  0.00,  0.02),

  139.         /** Transformation from ITRF 2020 To ITRF 88. */
  140.         ITRF_2020_TO_ITRF_1988(ITRFVersion.ITRF_2020, ITRFVersion.ITRF_1988, 2015,
  141.                                24.5, -3.9, -169.9,  0.10,  0.00,  0.36,
  142.                                 0.1, -0.6,   -3.1,  0.00,  0.00,  0.02),

  143.         // see http://itrf.ign.fr/doc_ITRF/Transfo-ITRF2014_ITRFs.txt
  144.         // SOLUTION         Tx       Ty       Tz        D        Rx        Ry        Rz      EPOCH
  145.         // UNITS----------> mm       mm       mm       ppb       .001"     .001"     .001"
  146.         //                  .        .        .         .        .         .         .
  147.         //        RATES     Tx       Ty       Tz        D        Rx        Ry        Rz
  148.         // UNITS----------> mm/y     mm/y     mm/y     ppb/y    .001"/y   .001"/y   .001"/y
  149.         // -----------------------------------------------------------------------------------------
  150.         //   ITRF2008        1.6      1.9      2.4     -0.02      0.00      0.00      0.00    2010.0
  151.         //        rates      0.0      0.0     -0.1      0.03      0.00      0.00      0.00
  152.         //   ITRF2005        2.6      1.0     -2.3      0.92      0.00      0.00      0.00    2010.0
  153.         //        rates      0.3      0.0     -0.1      0.03      0.00      0.00      0.00
  154.         //   ITRF2000        0.7      1.2    -26.1      2.12      0.00      0.00      0.00    2010.0
  155.         //        rates      0.1      0.1     -1.9      0.11      0.00      0.00      0.00
  156.         //   ITRF97          7.4     -0.5    -62.8      3.80      0.00      0.00      0.26    2010.0
  157.         //        rates      0.1     -0.5     -3.3      0.12      0.00      0.00      0.02
  158.         //   ITRF96          7.4     -0.5    -62.8      3.80      0.00      0.00      0.26    2010.0
  159.         //        rates      0.1     -0.5     -3.3      0.12      0.00      0.00      0.02
  160.         //   ITRF94          7.4     -0.5    -62.8      3.80      0.00      0.00      0.26    2010.0
  161.         //        rates      0.1     -0.5     -3.3      0.12      0.00      0.00      0.02
  162.         //   ITRF93        -50.4      3.3    -60.2      4.29     -2.81     -3.38      0.40    2010.0
  163.         //        rates     -2.8     -0.1     -2.5      0.12     -0.11     -0.19      0.07
  164.         //   ITRF92         15.4      1.5    -70.8      3.09      0.00      0.00      0.26    2010.0
  165.         //        rates      0.1     -0.5     -3.3      0.12      0.00      0.00      0.02
  166.         //   ITRF91         27.4     15.5    -76.8      4.49      0.00      0.00      0.26    2010.0
  167.         //        rates      0.1     -0.5     -3.3      0.12      0.00      0.00      0.02
  168.         //   ITRF90         25.4     11.5    -92.8      4.79      0.00      0.00      0.26    2010.0
  169.         //        rates      0.1     -0.5     -3.3      0.12      0.00      0.00      0.02
  170.         //   ITRF89         30.4     35.5   -130.8      8.19      0.00      0.00      0.26    2010.0
  171.         //        rates      0.1     -0.5     -3.3      0.12      0.00      0.00      0.02
  172.         //   ITRF88         25.4     -0.5   -154.8     11.29      0.10      0.00      0.26    2010.0
  173.         //        rates      0.1     -0.5     -3.3      0.12      0.00      0.00      0.02
  174.         // _________________________________________________________________________________________

  175.         /** Transformation from ITRF 2014 To ITRF 2008. */
  176.         ITRF_2014_TO_ITRF_2008(ITRFVersion.ITRF_2014, ITRFVersion.ITRF_2008, 2010,
  177.                                 1.6, 1.9,     2.4, 0.00, 0.00, 0.00,
  178.                                 0.0, 0.0,    -0.1, 0.00, 0.00, 0.00),

  179.         /** Transformation from ITRF 2014 To ITRF 2005. */
  180.         ITRF_2014_TO_ITRF_2005(ITRFVersion.ITRF_2014, ITRFVersion.ITRF_2005, 2010,
  181.                                 2.6, 1.0,    -2.3, 0.00, 0.00, 0.00,
  182.                                 0.3, 0.0,    -0.1, 0.00, 0.00, 0.00),

  183.         /** Transformation from ITRF 2014 To ITRF 2000. */
  184.         ITRF_2014_TO_ITRF_2000(ITRFVersion.ITRF_2014, ITRFVersion.ITRF_2000, 2010,
  185.                                0.7, 1.2,   -26.1, 0.00, 0.00, 0.00,
  186.                                0.1, 0.1,    -1.9, 0.00, 0.00, 0.00),

  187.         /** Transformation from ITRF 2014 To ITRF 97. */
  188.         ITRF_2014_TO_ITRF_1997(ITRFVersion.ITRF_2014, ITRFVersion.ITRF_1997, 2010,
  189.                                7.4, -0.5,  -62.8, 0.00, 0.00, 0.26,
  190.                                0.1, -0.5,   -3.3, 0.00, 0.00, 0.02),

  191.         /** Transformation from ITRF 2014 To ITRF 96. */
  192.         ITRF_2014_TO_ITRF_1996(ITRFVersion.ITRF_2014, ITRFVersion.ITRF_1996, 2010,
  193.                                7.4, -0.5,  -62.8, 0.00, 0.00, 0.26,
  194.                                0.1, -0.5,  -3.3, 0.00, 0.00, 0.02),

  195.         /** Transformation from ITRF 2014 To ITRF 94. */
  196.         ITRF_2014_TO_ITRF_1994(ITRFVersion.ITRF_2014, ITRFVersion.ITRF_1994, 2010,
  197.                                7.4, -0.5,  -62.8, 0.00, 0.00, 0.26,
  198.                                0.1, -0.5,   -3.3, 0.00, 0.00, 0.02),

  199.         /** Transformation from ITRF 2014 To ITRF 93. */
  200.         ITRF_2014_TO_ITRF_1993(ITRFVersion.ITRF_2014, ITRFVersion.ITRF_1993, 2010,
  201.                                -50.4,  3.3,  -60.2, -2.81, -3.38, 0.40,
  202.                                -2.8, -0.1,   -2.5, -0.11, -0.19, 0.07),

  203.         /** Transformation from ITRF 2014 To ITRF 92. */
  204.         ITRF_2014_TO_ITRF_1992(ITRFVersion.ITRF_2014, ITRFVersion.ITRF_1992, 2010,
  205.                                15.4,  1.5,  -70.8, 0.00, 0.00, 0.26,
  206.                                0.1, -0.5,   -3.3, 0.00, 0.00, 0.02),

  207.         /** Transformation from ITRF 2014 To ITRF 91. */
  208.         ITRF_2014_TO_ITRF_1991(ITRFVersion.ITRF_2014, ITRFVersion.ITRF_1991, 2010,
  209.                                27.4, 15.5,  -76.8, 0.00, 0.00, 0.26,
  210.                                0.1, -0.5,   -3.3, 0.00, 0.00, 0.02),

  211.         /** Transformation from ITRF 2014 To ITRF 90. */
  212.         ITRF_2014_TO_ITRF_1990(ITRFVersion.ITRF_2014, ITRFVersion.ITRF_1990, 2010,
  213.                                25.4, 11.5,  -92.8, 0.00, 0.00, 0.26,
  214.                                0.1, -0.5,   -3.3, 0.00, 0.00, 0.02),

  215.         /** Transformation from ITRF 2014 To ITRF 89. */
  216.         ITRF_2014_TO_ITRF_1989(ITRFVersion.ITRF_2014, ITRFVersion.ITRF_1989, 2010,
  217.                                30.4, 35.5, -130.8, 0.00, 0.00, 0.26,
  218.                                0.1, -0.5,   -3.3, 0.00, 0.00, 0.02),

  219.         /** Transformation from ITRF 2014 To ITRF 88. */
  220.         ITRF_2014_TO_ITRF_1988(ITRFVersion.ITRF_2014, ITRFVersion.ITRF_1988, 2010,
  221.                                25.4, -0.5, -154.8, 0.10, 0.00, 0.26,
  222.                                0.1, -0.5,   -3.3, 0.00, 0.00, 0.02),

  223.         // see http://itrf.ensg.ign.fr/doc_ITRF/Transfo-ITRF2008_ITRFs.txt
  224.         // SOLUTION         Tx       Ty       Tz        D        Rx        Ry        Rz      EPOCH
  225.         // UNITS----------> mm       mm       mm       ppb       .001"     .001"     .001"
  226.         //                         .        .        .         .        .         .         .
  227.         //        RATES     Tx       Ty       Tz        D        Rx        Ry        Rz
  228.         // UNITS----------> mm/y     mm/y     mm/y     ppb/y    .001"/y   .001"/y   .001"/y
  229.         // -----------------------------------------------------------------------------------------
  230.         //   ITRF2005       -2.0     -0.9     -4.7      0.94      0.00      0.00      0.00    2000.0
  231.         //        rates      0.3      0.0      0.0      0.00      0.00      0.00      0.00
  232.         //   ITRF2000       -1.9     -1.7    -10.5      1.34      0.00      0.00      0.00    2000.0
  233.         //        rates      0.1      0.1     -1.8      0.08      0.00      0.00      0.00
  234.         //   ITRF97          4.8      2.6    -33.2      2.92      0.00      0.00      0.06    2000.0
  235.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  236.         //   ITRF96          4.8      2.6    -33.2      2.92      0.00      0.00      0.06    2000.0
  237.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  238.         //   ITRF94          4.8      2.6    -33.2      2.92      0.00      0.00      0.06    2000.0
  239.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  240.         //   ITRF93        -24.0      2.4    -38.6      3.41     -1.71     -1.48     -0.30    2000.0
  241.         //        rates     -2.8     -0.1     -2.4      0.09     -0.11     -0.19      0.07
  242.         //   ITRF92         12.8      4.6    -41.2      2.21      0.00      0.00      0.06    2000.0
  243.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  244.         //   ITRF91         24.8     18.6    -47.2      3.61      0.00      0.00      0.06    2000.0
  245.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  246.         //   ITRF90         22.8     14.6    -63.2      3.91      0.00      0.00      0.06    2000.0
  247.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  248.         //   ITRF89         27.8     38.6   -101.2      7.31      0.00      0.00      0.06    2000.0
  249.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  250.         //   ITRF88         22.8      2.6   -125.2     10.41      0.10      0.00      0.06    2000.0
  251.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  252.         // _________________________________________________________________________________________

  253.         /** Transformation from ITRF 2008 To ITRF 2005. */
  254.         ITRF_2008_TO_ITRF_2005(ITRFVersion.ITRF_2008, ITRFVersion.ITRF_2005, 2000,
  255.                                -2.0, -0.9,   -4.7,  0.00,  0.00,  0.00,
  256.                                 0.3,  0.0,    0.0,  0.00,  0.00,  0.00),

  257.         /** Transformation from ITRF 2008 To ITRF 2000. */
  258.         ITRF_2008_TO_ITRF_2000(ITRFVersion.ITRF_2008, ITRFVersion.ITRF_2000, 2000,
  259.                                -1.9, -1.7,  -10.5,  0.00,  0.00,  0.00,
  260.                                 0.1,  0.1,   -1.8,  0.00,  0.00,  0.00),

  261.         /** Transformation from ITRF 2008 To ITRF 97. */
  262.         ITRF_2008_TO_ITRF_1997(ITRFVersion.ITRF_2008, ITRFVersion.ITRF_1997, 2000,
  263.                                4.8,  2.6,  -33.2,  0.00,  0.00,  0.06,
  264.                                0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  265.         /** Transformation from ITRF 2008 To ITRF 96. */
  266.         ITRF_2008_TO_ITRF_1996(ITRFVersion.ITRF_2008, ITRFVersion.ITRF_1996, 2000,
  267.                                4.8,  2.6,  -33.2,  0.00,  0.00,  0.06,
  268.                                0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  269.         /** Transformation from ITRF 2008 To ITRF 94. */
  270.         ITRF_2008_TO_ITRF_1994(ITRFVersion.ITRF_2008, ITRFVersion.ITRF_1994, 2000,
  271.                                4.8,  2.6,  -33.2,  0.00,  0.00,  0.06,
  272.                                0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  273.         /** Transformation from ITRF 2008 To ITRF 93. */
  274.         ITRF_2008_TO_ITRF_1993(ITRFVersion.ITRF_2008, ITRFVersion.ITRF_1993, 2000,
  275.                                -24.0,  2.4,  -38.6, -1.71, -1.48, -0.30,
  276.                                -2.8, -0.1,   -2.4, -0.11, -0.19,  0.07),

  277.         /** Transformation from ITRF 2008 To ITRF 92. */
  278.         ITRF_2008_TO_ITRF_1992(ITRFVersion.ITRF_2008, ITRFVersion.ITRF_1992, 2000,
  279.                                12.8,  4.6,  -41.2,  0.00,  0.00,  0.06,
  280.                                0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  281.         /** Transformation from ITRF 2008 To ITRF 91. */
  282.         ITRF_2008_TO_ITRF_1991(ITRFVersion.ITRF_2008, ITRFVersion.ITRF_1991, 2000,
  283.                                24.8, 18.6,  -47.2,  0.00,  0.00,  0.06,
  284.                                0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  285.         /** Transformation from ITRF 2008 To ITRF 90. */
  286.         ITRF_2008_TO_ITRF_1990(ITRFVersion.ITRF_2008, ITRFVersion.ITRF_1990, 2000,
  287.                                22.8, 14.6,  -63.2,  0.00,  0.00,  0.06,
  288.                                0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  289.         /** Transformation from ITRF 2008 To ITRF 89. */
  290.         ITRF_2008_TO_ITRF_1989(ITRFVersion.ITRF_2008, ITRFVersion.ITRF_1989, 2000,
  291.                                27.8, 38.6, -101.2,  0.00,  0.00,  0.06,
  292.                                0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  293.         /** Transformation from ITRF 2008 To ITRF 88. */
  294.         ITRF_2008_TO_ITRF_1988(ITRFVersion.ITRF_2008, ITRFVersion.ITRF_1988, 2000,
  295.                                22.8,  2.6, -125.2,  0.10,  0.00,  0.06,
  296.                                0.1, -0.5,   -3.2,  0.00,  0.00,  0.02);

  297.         /** Origin ITRF. */
  298.         private final ITRFVersion origin;

  299.         /** Destination ITRF. */
  300.         private final ITRFVersion destination;

  301.         /** Transformation. */
  302.         private final transient HelmertTransformationWithoutTimeScale transformation;

  303.         /** Simple constructor.
  304.          * @param origin origin ITRF
  305.          * @param destination destination ITRF
  306.          * @param refYear reference year for the epoch of the transform
  307.          * @param t1 translation parameter along X axis (BEWARE, this is in mm)
  308.          * @param t2 translation parameter along Y axis (BEWARE, this is in mm)
  309.          * @param t3 translation parameter along Z axis (BEWARE, this is in mm)
  310.          * @param r1 rotation parameter around X axis (BEWARE, this is in mas)
  311.          * @param r2 rotation parameter around Y axis (BEWARE, this is in mas)
  312.          * @param r3 rotation parameter around Z axis (BEWARE, this is in mas)
  313.          * @param t1Dot rate of translation parameter along X axis (BEWARE, this is in mm/y)
  314.          * @param t2Dot rate of translation parameter along Y axis (BEWARE, this is in mm/y)
  315.          * @param t3Dot rate of translation parameter along Z axis (BEWARE, this is in mm/y)
  316.          * @param r1Dot rate of rotation parameter around X axis (BEWARE, this is in mas/y)
  317.          * @param r2Dot rate of rotation parameter around Y axis (BEWARE, this is in mas/y)
  318.          * @param r3Dot rate of rotation parameter around Z axis (BEWARE, this is in mas/y)
  319.          */
  320.         Predefined(final ITRFVersion origin, final ITRFVersion destination, final int refYear,
  321.                    final double t1, final double t2, final double t3,
  322.                    final double r1, final double r2, final double r3,
  323.                    final double t1Dot, final double t2Dot, final double t3Dot,
  324.                    final double r1Dot, final double r2Dot, final double r3Dot) {
  325.             this.origin         = origin;
  326.             this.destination    = destination;
  327.             this.transformation =
  328.                     new HelmertTransformationWithoutTimeScale(new DateTimeComponents(refYear, 1, 1, 12, 0, 0),
  329.                                               t1, t2, t3, r1, r2, r3, t1Dot, t2Dot, t3Dot, r1Dot, r2Dot, r3Dot);
  330.         }

  331.         /** Get the origin ITRF.
  332.          * @return origin ITRF
  333.          * @since 9.2
  334.          */
  335.         public ITRFVersion getOrigin() {
  336.             return origin;
  337.         }

  338.         /** Get the destination ITRF.
  339.          * @return destination ITRF
  340.          * @since 9.2
  341.          */
  342.         public ITRFVersion getDestination() {
  343.             return destination;
  344.         }

  345.         /** Get the underlying {@link HelmertTransformation}.
  346.          *
  347.          * <p>This method uses the {@link DataContext#getDefault() default data context}.
  348.          *
  349.          * @return underlying {@link HelmertTransformation}
  350.          * @since 9.2
  351.          * @see #getTransformation(TimeScale)
  352.          */
  353.         @DefaultDataContext
  354.         public HelmertTransformation getTransformation() {
  355.             return getTransformation(DataContext.getDefault().getTimeScales().getTT());
  356.         }

  357.         /** Get the underlying {@link HelmertTransformation}.
  358.          * @return underlying {@link HelmertTransformation}
  359.          * @param tt TT time scale.
  360.          * @since 10.1
  361.          */
  362.         public HelmertTransformation getTransformation(final TimeScale tt) {
  363.             return transformation.withTimeScale(tt);
  364.         }

  365.         /** Create an ITRF frame by transforming another ITRF frame.
  366.          *
  367.          * <p>This method uses the {@link DataContext#getDefault() default data context}.
  368.          *
  369.          * @param parent parent ITRF frame
  370.          * @param name name of the frame to create
  371.          * @return new ITRF frame
  372.          * @see #createTransformedITRF(Frame, String, TimeScale)
  373.          */
  374.         @DefaultDataContext
  375.         public Frame createTransformedITRF(final Frame parent, final String name) {
  376.             return createTransformedITRF(parent, name,
  377.                     DataContext.getDefault().getTimeScales().getTT());
  378.         }

  379.         /** Create an ITRF frame by transforming another ITRF frame.
  380.          * @param parent parent ITRF frame
  381.          * @param name name of the frame to create
  382.          * @param tt TT time scale.
  383.          * @return new ITRF frame
  384.          * @since 10.1
  385.          */
  386.         public Frame createTransformedITRF(final Frame parent,
  387.                                            final String name,
  388.                                            final TimeScale tt) {
  389.             return new Frame(parent, getTransformation(tt), name);
  390.         }

  391.         /** Select a predefined transform between two years.
  392.          * @param origin origin year
  393.          * @param destination destination year
  394.          * @return predefined transform from origin to destination, or null if no such predefined transform exist
  395.          * @since 11.2
  396.          */
  397.         public static Predefined selectPredefined(final int origin, final int destination) {
  398.             final Optional<HelmertTransformation.Predefined> optional =
  399.                             Stream.
  400.                             of(HelmertTransformation.Predefined.values()).
  401.                             filter(p -> p.getOrigin().getYear() == origin && p.getDestination().getYear() == destination).
  402.                             findFirst();
  403.             return optional.isPresent() ? optional.get() : null;
  404.         }

  405.     }

  406.     /**
  407.      * A {@link HelmertTransformation} without reference to a {@link TimeScale}. This
  408.      * class is needed to maintain compatibility with Orekit 10.0 since {@link Predefined}
  409.      * is an enum and it had a reference to the TT time scale.
  410.      */
  411.     private static class HelmertTransformationWithoutTimeScale {

  412.         /** Cartesian part of the transform. */
  413.         private final PVCoordinates cartesian;

  414.         /** Global rotation vector (applying rotation is done by computing cross product). */
  415.         private final Vector3D rotationVector;

  416.         /** First time derivative of the rotation (norm representing angular rate). */
  417.         private final Vector3D rotationRate;

  418.         /** Reference epoch of the transform. */
  419.         private final DateTimeComponents epoch;

  420.         /** Build a transform from its primitive operations.
  421.          * @param epoch reference epoch of the transform
  422.          * @param t1 translation parameter along X axis (BEWARE, this is in mm)
  423.          * @param t2 translation parameter along Y axis (BEWARE, this is in mm)
  424.          * @param t3 translation parameter along Z axis (BEWARE, this is in mm)
  425.          * @param r1 rotation parameter around X axis (BEWARE, this is in mas)
  426.          * @param r2 rotation parameter around Y axis (BEWARE, this is in mas)
  427.          * @param r3 rotation parameter around Z axis (BEWARE, this is in mas)
  428.          * @param t1Dot rate of translation parameter along X axis (BEWARE, this is in mm/y)
  429.          * @param t2Dot rate of translation parameter along Y axis (BEWARE, this is in mm/y)
  430.          * @param t3Dot rate of translation parameter along Z axis (BEWARE, this is in mm/y)
  431.          * @param r1Dot rate of rotation parameter around X axis (BEWARE, this is in mas/y)
  432.          * @param r2Dot rate of rotation parameter around Y axis (BEWARE, this is in mas/y)
  433.          * @param r3Dot rate of rotation parameter around Z axis (BEWARE, this is in mas/y)
  434.          */
  435.         HelmertTransformationWithoutTimeScale(
  436.                 final DateTimeComponents epoch,
  437.                 final double t1, final double t2, final double t3,
  438.                 final double r1, final double r2, final double r3,
  439.                 final double t1Dot, final double t2Dot, final double t3Dot,
  440.                 final double r1Dot, final double r2Dot, final double r3Dot) {

  441.             // conversion parameters to SI units
  442.             final double mmToM    = 1.0e-3;
  443.             final double masToRad = 1.0e-3 * Constants.ARC_SECONDS_TO_RADIANS;

  444.             this.epoch          = epoch;
  445.             this.cartesian = new PVCoordinates(new Vector3D(t1 * mmToM,
  446.                     t2 * mmToM,
  447.                     t3 * mmToM),
  448.                     new Vector3D(t1Dot * mmToM / Constants.JULIAN_YEAR,
  449.                             t2Dot * mmToM / Constants.JULIAN_YEAR,
  450.                             t3Dot * mmToM / Constants.JULIAN_YEAR));
  451.             this.rotationVector = new Vector3D(r1 * masToRad,
  452.                     r2 * masToRad,
  453.                     r3 * masToRad);
  454.             this.rotationRate   = new Vector3D(r1Dot * masToRad / Constants.JULIAN_YEAR,
  455.                     r2Dot * masToRad / Constants.JULIAN_YEAR,
  456.                     r3Dot * masToRad / Constants.JULIAN_YEAR);

  457.         }

  458.         /**
  459.          * Get the Helmert transformation with reference to the given time scale.
  460.          *
  461.          * @param tt TT time scale.
  462.          * @return Helmert transformation.
  463.          */
  464.         public HelmertTransformation withTimeScale(final TimeScale tt) {
  465.             return new HelmertTransformation(cartesian, rotationVector, rotationRate,
  466.                     new AbsoluteDate(epoch, tt));
  467.         }

  468.     }

  469.     /** Cartesian part of the transform. */
  470.     private final PVCoordinates cartesian;

  471.     /** Global rotation vector (applying rotation is done by computing cross product). */
  472.     private final Vector3D rotationVector;

  473.     /** First time derivative of the rotation (norm representing angular rate). */
  474.     private final Vector3D rotationRate;

  475.     /** Reference epoch of the transform. */
  476.     private final AbsoluteDate epoch;

  477.     /** Build a transform from its primitive operations.
  478.      * @param epoch reference epoch of the transform
  479.      * @param t1 translation parameter along X axis (BEWARE, this is in mm)
  480.      * @param t2 translation parameter along Y axis (BEWARE, this is in mm)
  481.      * @param t3 translation parameter along Z axis (BEWARE, this is in mm)
  482.      * @param r1 rotation parameter around X axis (BEWARE, this is in mas)
  483.      * @param r2 rotation parameter around Y axis (BEWARE, this is in mas)
  484.      * @param r3 rotation parameter around Z axis (BEWARE, this is in mas)
  485.      * @param t1Dot rate of translation parameter along X axis (BEWARE, this is in mm/y)
  486.      * @param t2Dot rate of translation parameter along Y axis (BEWARE, this is in mm/y)
  487.      * @param t3Dot rate of translation parameter along Z axis (BEWARE, this is in mm/y)
  488.      * @param r1Dot rate of rotation parameter around X axis (BEWARE, this is in mas/y)
  489.      * @param r2Dot rate of rotation parameter around Y axis (BEWARE, this is in mas/y)
  490.      * @param r3Dot rate of rotation parameter around Z axis (BEWARE, this is in mas/y)
  491.      */
  492.     public HelmertTransformation(final AbsoluteDate epoch,
  493.                                  final double t1, final double t2, final double t3,
  494.                                  final double r1, final double r2, final double r3,
  495.                                  final double t1Dot, final double t2Dot, final double t3Dot,
  496.                                  final double r1Dot, final double r2Dot, final double r3Dot) {

  497.         // conversion parameters to SI units
  498.         final double mmToM    = 1.0e-3;
  499.         final double masToRad = 1.0e-3 * Constants.ARC_SECONDS_TO_RADIANS;

  500.         this.epoch          = epoch;
  501.         this.cartesian = new PVCoordinates(new Vector3D(t1 * mmToM,
  502.                                                         t2 * mmToM,
  503.                                                         t3 * mmToM),
  504.                                            new Vector3D(t1Dot * mmToM / Constants.JULIAN_YEAR,
  505.                                                         t2Dot * mmToM / Constants.JULIAN_YEAR,
  506.                                                         t3Dot * mmToM / Constants.JULIAN_YEAR));
  507.         this.rotationVector = new Vector3D(r1 * masToRad,
  508.                                            r2 * masToRad,
  509.                                            r3 * masToRad);
  510.         this.rotationRate   = new Vector3D(r1Dot * masToRad / Constants.JULIAN_YEAR,
  511.                                            r2Dot * masToRad / Constants.JULIAN_YEAR,
  512.                                            r3Dot * masToRad / Constants.JULIAN_YEAR);

  513.     }

  514.     /**
  515.      * Private constructor.
  516.      *
  517.      * @param cartesian      part of the transform.
  518.      * @param rotationVector global rotation vector.
  519.      * @param rotationRate   time derivative of rotation.
  520.      * @param epoch          of transform.
  521.      */
  522.     private HelmertTransformation(final PVCoordinates cartesian,
  523.                                   final Vector3D rotationVector,
  524.                                   final Vector3D rotationRate,
  525.                                   final AbsoluteDate epoch) {
  526.         this.cartesian = cartesian;
  527.         this.rotationVector = rotationVector;
  528.         this.rotationRate = rotationRate;
  529.         this.epoch = epoch;
  530.     }

  531.     /** Get the reference epoch of the transform.
  532.      * @return reference epoch of the transform
  533.      */
  534.     public AbsoluteDate getEpoch() {
  535.         return epoch;
  536.     }

  537.     /** {@inheritDoc} */
  538.     @Override
  539.     public Transform getTransform(final AbsoluteDate date) {

  540.         // compute parameters evolution since reference epoch
  541.         final double dt = date.durationFrom(epoch);
  542.         final Vector3D dR = new Vector3D(1, rotationVector, dt, rotationRate);

  543.         // build translation part
  544.         final Transform translationTransform = new Transform(date, cartesian.shiftedBy(dt));

  545.         // build rotation part
  546.         final double angle = dR.getNorm();
  547.         final Transform rotationTransform =
  548.                 new Transform(date,
  549.                               (angle < Precision.SAFE_MIN) ?
  550.                               Rotation.IDENTITY :
  551.                               new Rotation(dR, angle, RotationConvention.VECTOR_OPERATOR),
  552.                               rotationRate);

  553.         // combine both parts
  554.         return new Transform(date, translationTransform, rotationTransform);

  555.     }

  556.     /** {@inheritDoc} */
  557.     @Override
  558.     public StaticTransform getStaticTransform(final AbsoluteDate date) {

  559.         // compute parameters evolution since reference epoch
  560.         final double dt = date.durationFrom(epoch);
  561.         final Vector3D dR = new Vector3D(1, rotationVector, dt, rotationRate);

  562.         // build translation part
  563.         final Vector3D translation = cartesian.shiftedBy(dt).getPosition();

  564.         // build rotation part
  565.         final double angle = dR.getNorm();
  566.         final Rotation rotation = (angle < Precision.SAFE_MIN) ?
  567.                 Rotation.IDENTITY :
  568.                 new Rotation(dR, angle, RotationConvention.VECTOR_OPERATOR);

  569.         // combine both parts
  570.         return StaticTransform.of(date, translation, rotation);

  571.     }

  572.     /** {@inheritDoc} */
  573.     @Override
  574.     public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {

  575.         // compute parameters evolution since reference epoch
  576.         final T dt = date.durationFrom(epoch);
  577.         final FieldVector3D<T> dR = new FieldVector3D<>(date.getField().getOne(), rotationVector,
  578.                                                         dt, rotationRate);

  579.         // build translation part
  580.         final FieldTransform<T> translationTransform =
  581.                         new FieldTransform<>(date,
  582.                                              new FieldPVCoordinates<>(date.getField(), cartesian).shiftedBy(dt));

  583.         // build rotation part
  584.         final T angle = dR.getNorm();
  585.         final FieldTransform<T> rotationTransform =
  586.                 new FieldTransform<>(date,
  587.                                     (angle.getReal() < Precision.SAFE_MIN) ?
  588.                                      FieldRotation.getIdentity(date.getField()) :
  589.                                     new FieldRotation<>(dR, angle, RotationConvention.VECTOR_OPERATOR),
  590.                                     new FieldVector3D<>(date.getField(), rotationRate));

  591.         // combine both parts
  592.         return new FieldTransform<>(date, translationTransform, rotationTransform);

  593.     }

  594. }