HelmertTransformation.java

  1. /* Copyright 2002-2013 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.apache.commons.math3.geometry.euclidean.threed.Rotation;
  19. import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
  20. import org.apache.commons.math3.util.Precision;
  21. import org.orekit.time.AbsoluteDate;
  22. import org.orekit.time.TimeScalesFactory;
  23. import org.orekit.utils.Constants;
  24. import org.orekit.utils.PVCoordinates;


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

  42.     /** serializable UID. */
  43.     private static final long serialVersionUID = -1900615992141291146L;

  44.     /** Enumerate for predefined Helmert transformations. */
  45.     public enum Predefined {

  46.         // see http://itrf.ensg.ign.fr/doc_ITRF/Transfo-ITRF2008_ITRFs.txt
  47.         // SOLUTION         Tx       Ty       Tz        D        Rx        Ry        Rz      EPOCH
  48.         // UNITS----------> mm       mm       mm       ppb       .001"     .001"     .001"
  49.         //                         .        .        .         .        .         .         .
  50.         //        RATES     Tx       Ty       Tz        D        Rx        Ry        Rz
  51.         // UNITS----------> mm/y     mm/y     mm/y     ppb/y    .001"/y   .001"/y   .001"/y
  52.         // -----------------------------------------------------------------------------------------
  53.         //   ITRF2005       -2.0     -0.9     -4.7      0.94      0.00      0.00      0.00    2000.0
  54.         //        rates      0.3      0.0      0.0      0.00      0.00      0.00      0.00
  55.         //   ITRF2000       -1.9     -1.7    -10.5      1.34      0.00      0.00      0.00    2000.0
  56.         //        rates      0.1      0.1     -1.8      0.08      0.00      0.00      0.00
  57.         //   ITRF97          4.8      2.6    -33.2      2.92      0.00      0.00      0.06    2000.0
  58.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  59.         //   ITRF96          4.8      2.6    -33.2      2.92      0.00      0.00      0.06    2000.0
  60.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  61.         //   ITRF94          4.8      2.6    -33.2      2.92      0.00      0.00      0.06    2000.0
  62.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  63.         //   ITRF93        -24.0      2.4    -38.6      3.41     -1.71     -1.48     -0.30    2000.0
  64.         //        rates     -2.8     -0.1     -2.4      0.09     -0.11     -0.19      0.07
  65.         //   ITRF92         12.8      4.6    -41.2      2.21      0.00      0.00      0.06    2000.0
  66.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  67.         //   ITRF91         24.8     18.6    -47.2      3.61      0.00      0.00      0.06    2000.0
  68.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  69.         //   ITRF90         22.8     14.6    -63.2      3.91      0.00      0.00      0.06    2000.0
  70.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  71.         //   ITRF89         27.8     38.6   -101.2      7.31      0.00      0.00      0.06    2000.0
  72.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  73.         //   ITRF88         22.8      2.6   -125.2     10.41      0.10      0.00      0.06    2000.0
  74.         //        rates      0.1     -0.5     -3.2      0.09      0.00      0.00      0.02
  75.         // _________________________________________________________________________________________

  76.         /** Transformation from ITRF 2008 To ITRF 2005. */
  77.         ITRF_2008_TO_ITRF_2005(2000,
  78.                                 -2.0, -0.9,   -4.7,  0.00,  0.00,  0.00,
  79.                                  0.3,  0.0,    0.0,  0.00,  0.00,  0.00),

  80.         /** Transformation from ITRF 2008 To ITRF 2000. */
  81.         ITRF_2008_TO_ITRF_2000(2000,
  82.                                 -1.9, -1.7,  -10.5,  0.00,  0.00,  0.00,
  83.                                  0.1,  0.1,   -1.8,  0.00,  0.00,  0.00),

  84.         /** Transformation from ITRF 2008 To ITRF 97. */
  85.         ITRF_2008_TO_ITRF_97  (2000,
  86.                                  4.8,  2.6,  -33.2,  0.00,  0.00,  0.06,
  87.                                  0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  88.         /** Transformation from ITRF 2008 To ITRF 96. */
  89.         ITRF_2008_TO_ITRF_96  (2000,
  90.                                  4.8,  2.6,  -33.2,  0.00,  0.00,  0.06,
  91.                                  0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  92.         /** Transformation from ITRF 2008 To ITRF 94. */
  93.         ITRF_2008_TO_ITRF_94  (2000,
  94.                                  4.8,  2.6,  -33.2,  0.00,  0.00,  0.06,
  95.                                  0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  96.         /** Transformation from ITRF 2008 To ITRF 93. */
  97.         ITRF_2008_TO_ITRF_93  (2000,
  98.                                -24.0,  2.4,  -38.6, -1.71, -1.48, -0.30,
  99.                                 -2.8, -0.1,   -2.4, -0.11, -0.19,  0.07),

  100.         /** Transformation from ITRF 2008 To ITRF 92. */
  101.         ITRF_2008_TO_ITRF_92  (2000,
  102.                                 12.8,  4.6,  -41.2,  0.00,  0.00,  0.06,
  103.                                  0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  104.         /** Transformation from ITRF 2008 To ITRF 91. */
  105.         ITRF_2008_TO_ITRF_91  (2000,
  106.                                 24.8, 18.6,  -47.2,  0.00,  0.00,  0.06,
  107.                                  0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  108.         /** Transformation from ITRF 2008 To ITRF 90. */
  109.         ITRF_2008_TO_ITRF_90  (2000,
  110.                                 22.8, 14.6,  -63.2,  0.00,  0.00,  0.06,
  111.                                  0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  112.         /** Transformation from ITRF 2008 To ITRF 89. */
  113.         ITRF_2008_TO_ITRF_89  (2000,
  114.                                 27.8, 38.6, -101.2,  0.00,  0.00,  0.06,
  115.                                  0.1, -0.5,   -3.2,  0.00,  0.00,  0.02),

  116.         /** Transformation from ITRF 2008 To ITRF 88. */
  117.         ITRF_2008_TO_ITRF_88  (2000,
  118.                                 22.8,  2.6, -125.2,  0.10,  0.00,  0.06,
  119.                                  0.1, -0.5,   -3.2,  0.00,  0.00,  0.02);

  120.         /** Transformation. */
  121.         private final HelmertTransformation transformation;

  122.         /** Simple constructor.
  123.          * @param refYear reference year for the epoch of the transform
  124.          * @param t1 translation parameter along X axis (BEWARE, this is in mm)
  125.          * @param t2 translation parameter along Y axis (BEWARE, this is in mm)
  126.          * @param t3 translation parameter along Z axis (BEWARE, this is in mm)
  127.          * @param r1 rotation parameter around X axis (BEWARE, this is in mas)
  128.          * @param r2 rotation parameter around Y axis (BEWARE, this is in mas)
  129.          * @param r3 rotation parameter around Z axis (BEWARE, this is in mas)
  130.          * @param t1Dot rate of translation parameter along X axis (BEWARE, this is in mm/y)
  131.          * @param t2Dot rate of translation parameter along Y axis (BEWARE, this is in mm/y)
  132.          * @param t3Dot rate of translation parameter along Z axis (BEWARE, this is in mm/y)
  133.          * @param r1Dot rate of rotation parameter around X axis (BEWARE, this is in mas/y)
  134.          * @param r2Dot rate of rotation parameter around Y axis (BEWARE, this is in mas/y)
  135.          * @param r3Dot rate of rotation parameter around Z axis (BEWARE, this is in mas/y)
  136.          */
  137.         private Predefined(final int refYear,
  138.                            final double t1, final double t2, final double t3,
  139.                            final double r1, final double r2, final double r3,
  140.                            final double t1Dot, final double t2Dot, final double t3Dot,
  141.                            final double r1Dot, final double r2Dot, final double r3Dot) {
  142.             transformation =
  143.                     new HelmertTransformation(new AbsoluteDate(refYear, 1, 1, 12, 0, 0, TimeScalesFactory.getTT()),
  144.                                               t1, t2, t3, r1, r2, r3, t1Dot, t2Dot, t3Dot, r1Dot, r2Dot, r3Dot);
  145.         }

  146.         /** Create an ITRF frame by transforming another ITRF frame.
  147.          * @param parent parent ITRF frame
  148.          * @param name name of the frame to create
  149.          * @return new ITRF frame
  150.          */
  151.         public Frame createTransformedITRF(final Frame parent, final String name) {
  152.             return new Frame(parent, transformation, name);
  153.         }

  154.     }

  155.     /** Cartesian part of the transform. */
  156.     private final PVCoordinates cartesian;

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

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

  161.     /** Reference epoch of the transform. */
  162.     private final AbsoluteDate epoch;

  163.     /** Build a transform from its primitive operations.
  164.      * @param epoch reference epoch of the transform
  165.      * @param t1 translation parameter along X axis (BEWARE, this is in mm)
  166.      * @param t2 translation parameter along Y axis (BEWARE, this is in mm)
  167.      * @param t3 translation parameter along Z axis (BEWARE, this is in mm)
  168.      * @param r1 rotation parameter around X axis (BEWARE, this is in mas)
  169.      * @param r2 rotation parameter around Y axis (BEWARE, this is in mas)
  170.      * @param r3 rotation parameter around Z axis (BEWARE, this is in mas)
  171.      * @param t1Dot rate of translation parameter along X axis (BEWARE, this is in mm/y)
  172.      * @param t2Dot rate of translation parameter along Y axis (BEWARE, this is in mm/y)
  173.      * @param t3Dot rate of translation parameter along Z axis (BEWARE, this is in mm/y)
  174.      * @param r1Dot rate of rotation parameter around X axis (BEWARE, this is in mas/y)
  175.      * @param r2Dot rate of rotation parameter around Y axis (BEWARE, this is in mas/y)
  176.      * @param r3Dot rate of rotation parameter around Z axis (BEWARE, this is in mas/y)
  177.      */
  178.     public HelmertTransformation(final AbsoluteDate epoch,
  179.                                  final double t1, final double t2, final double t3,
  180.                                  final double r1, final double r2, final double r3,
  181.                                  final double t1Dot, final double t2Dot, final double t3Dot,
  182.                                  final double r1Dot, final double r2Dot, final double r3Dot) {

  183.         // conversion parameters to SI units
  184.         final double mmToM    = 1.0e-3;
  185.         final double masToRad = 1.0e-3 * Constants.ARC_SECONDS_TO_RADIANS;

  186.         this.epoch          = epoch;
  187.         this.cartesian = new PVCoordinates(new Vector3D(t1 * mmToM,
  188.                                                         t2 * mmToM,
  189.                                                         t3 * mmToM),
  190.                                            new Vector3D(t1Dot * mmToM / Constants.JULIAN_YEAR,
  191.                                                         t2Dot * mmToM / Constants.JULIAN_YEAR,
  192.                                                         t3Dot * mmToM / Constants.JULIAN_YEAR));
  193.         this.rotationVector = new Vector3D(r1 * masToRad,
  194.                                            r2 * masToRad,
  195.                                            r3 * masToRad);
  196.         this.rotationRate   = new Vector3D(r1Dot * masToRad / Constants.JULIAN_YEAR,
  197.                                            r2Dot * masToRad / Constants.JULIAN_YEAR,
  198.                                            r3Dot * masToRad / Constants.JULIAN_YEAR);

  199.     }

  200.     /** Get the reference epoch of the transform.
  201.      * @return reference epoch of the transform
  202.      */
  203.     public AbsoluteDate getEpoch() {
  204.         return epoch;
  205.     }

  206.     /** Compute the transform at some date.
  207.      * @param date date at which the transform is desired
  208.      * @return computed transform at specified date
  209.      */
  210.     public Transform getTransform(final AbsoluteDate date) {

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

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

  216.         // build rotation part
  217.         final double angle = dR.getNorm();
  218.         final Transform rotationTransform =
  219.                 new Transform(date,
  220.                               (angle < Precision.SAFE_MIN) ? Rotation.IDENTITY : new Rotation(dR, angle),
  221.                                                            rotationRate);

  222.         // combine both parts
  223.         return new Transform(date, translationTransform, rotationTransform);

  224.     }

  225. }