VEISProvider.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 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.DateComponents;
  27. import org.orekit.time.FieldAbsoluteDate;
  28. import org.orekit.time.TimeScales;
  29. import org.orekit.utils.Constants;

  30. /** Veis 1950 Frame.
  31.  * <p>Its parent frame is the {@link GTODProvider} without EOP correction application.
  32.  * <p>This frame is mainly provided for consistency with legacy softwares.</p>
  33.  * @author Pascal Parraud
  34.  */
  35. class VEISProvider implements TransformProvider {

  36.     /** Serializable UID. */
  37.     private static final long serialVersionUID = 20130530L;

  38.     /** 1st coef for Veis sidereal time computation in radians (100.075542 deg). */
  39.     private static final double VST0 = 1.746647708617871;

  40.     /** 2nd coef for Veis sidereal time computation in rad/s (0.985612288 deg/s). */
  41.     private static final double VST1 = 0.17202179573714597e-1;

  42.     /** Veis sidereal time derivative in rad/s. */
  43.     private static final double VSTD = 7.292115146705209e-5;

  44.     /** Set of time scales to use. */
  45.     private final transient TimeScales timeScales;

  46.     /** Reference date. */
  47.     private final AbsoluteDate vstReference;

  48.     /**
  49.      * Constructor for the singleton.
  50.      *
  51.      * @param timeScales to use when computing the transform.
  52.      */
  53.     VEISProvider(final TimeScales timeScales) {
  54.         this.timeScales = timeScales;
  55.         this.vstReference =
  56.                 new AbsoluteDate(DateComponents.FIFTIES_EPOCH, timeScales.getTAI());
  57.     }

  58.     /** {@inheritDoc} */
  59.     @Override
  60.     public Transform getTransform(final AbsoluteDate date) {

  61.         // offset from FIFTIES epoch (UT1 scale)
  62.         final double dtai = date.durationFrom(vstReference);
  63.         final double dutc = timeScales.getUTC().offsetFromTAI(date);
  64.         final double dut1 = 0.0; // fixed at 0 since Veis parent is GTOD frame WITHOUT EOP corrections

  65.         final double tut1 = dtai + dutc + dut1;
  66.         final double ttd  = tut1 / Constants.JULIAN_DAY;
  67.         final double rdtt = ttd - (int) ttd;

  68.         // compute Veis sidereal time, in radians
  69.         final double vst = (VST0 + VST1 * ttd + MathUtils.TWO_PI * rdtt) % MathUtils.TWO_PI;

  70.         // compute angular rotation of Earth, in rad/s
  71.         final Vector3D rotationRate = new Vector3D(-VSTD, Vector3D.PLUS_K);

  72.         // set up the transform from parent GTOD
  73.         return new Transform(date,
  74.                              new Rotation(Vector3D.PLUS_K, vst, RotationConvention.VECTOR_OPERATOR),
  75.                              rotationRate);

  76.     }

  77.     /** {@inheritDoc} */
  78.     @Override
  79.     public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {

  80.         // offset from FIFTIES epoch (UT1 scale)
  81.         final T dtai = date.durationFrom(vstReference);
  82.         final double dutc = timeScales.getUTC().offsetFromTAI(date.toAbsoluteDate());
  83.         final double dut1 = 0.0; // fixed at 0 since Veis parent is GTOD frame WITHOUT EOP corrections

  84.         final T tut1 = dtai.add(dutc + dut1);
  85.         final T ttd  = tut1.divide(Constants.JULIAN_DAY);
  86.         final T rdtt = ttd.subtract((int) ttd.getReal());

  87.         // compute Veis sidereal time, in radians
  88.         final T vst = ttd.multiply(VST1).add(rdtt.multiply(MathUtils.TWO_PI)).add(VST0).remainder(MathUtils.TWO_PI);

  89.         // compute angular rotation of Earth, in rad/s
  90.         final FieldVector3D<T> rotationRate = new FieldVector3D<>(date.getField().getZero().add(-VSTD),
  91.                                                                   Vector3D.PLUS_K);

  92.         // set up the transform from parent GTOD
  93.         return new FieldTransform<>(date,
  94.                                     new FieldRotation<>(FieldVector3D.getPlusK(date.getField()), vst,
  95.                                                         RotationConvention.VECTOR_OPERATOR),
  96.                                     rotationRate);

  97.     }

  98. }