TDBScale.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.time;

  18. import org.apache.commons.math3.util.FastMath;
  19. import org.orekit.utils.Constants;

  20. /** Barycentric Dynamic Time.
  21.  * <p>Time used to take account of time dilation when calculating orbits of planets,
  22.  * asteroids, comets and interplanetary spacecraft in the Solar system. It was based
  23.  * on a Dynamical time scale but was not well defined and not rigorously correct as
  24.  * a relativistic time scale. It was subsequently deprecated in favour of
  25.  * Barycentric Coordinate Time (TCB), but at the 2006 General Assembly of the
  26.  * International Astronomical Union TDB was rehabilitated by making it a specific
  27.  * fixed linear transformation of TCB.</p>
  28.  * <p>By convention, TDB = TT + 0.001658 sin(g) + 0.000014 sin(2g)seconds
  29.  * where g = 357.53 + 0.9856003 (JD - 2451545) degrees.</p>
  30.  * @author Aude Privat
  31.  */
  32. public class TDBScale implements TimeScale {

  33.     /** Serializable UID. */
  34.     private static final long serialVersionUID = 20131209L;

  35.     /** Package private constructor for the factory.
  36.      */
  37.     TDBScale() {
  38.     }

  39.     /** {@inheritDoc} */
  40.     public double offsetFromTAI(final AbsoluteDate date) {
  41.         final double dtDays = date.durationFrom(AbsoluteDate.J2000_EPOCH) / Constants.JULIAN_DAY;
  42.         final double g = FastMath.toRadians(357.53 + 0.9856003 * dtDays);
  43.         return TimeScalesFactory.getTT().offsetFromTAI(date) + (0.001658 * FastMath.sin(g) + 0.000014 * FastMath.sin(2 * g));
  44.     }

  45.     /** {@inheritDoc} */
  46.     public double offsetToTAI(final DateComponents date, final TimeComponents time) {
  47.         final AbsoluteDate reference = new AbsoluteDate(date, time, TimeScalesFactory.getTAI());
  48.         double offset = 0;
  49.         for (int i = 0; i < 3; i++) {
  50.             offset = -offsetFromTAI(reference.shiftedBy(offset));
  51.         }
  52.         return offset;
  53.     }

  54.     /** {@inheritDoc} */
  55.     public String getName() {
  56.         return "TDB";
  57.     }

  58.     /** {@inheritDoc} */
  59.     public String toString() {
  60.         return getName();
  61.     }

  62. }