TCBScale.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. /** Barycentric Coordinate Time.
  19.  * <p>Coordinate time at the center of mass of the Solar System.
  20.  * This time scale depends linearly from {@link TDBScale Barycentric Dynamical Time}.</p>
  21.  * <p>This is intended to be accessed thanks to the {@link TimeScalesFactory} class,
  22.  * so there is no public constructor.</p>
  23.  * @author Luc Maisonobe
  24.  * @see AbsoluteDate
  25.  */
  26. public class TCBScale implements TimeScale {

  27.     /** Serializable UID. */
  28.     private static final long serialVersionUID = 20131209L;

  29.     /** LG rate. */
  30.     private static final double LB_RATE = 1.550519768e-8;

  31.     /** Reference date for TCB.
  32.      * <p>The reference date is such that the four following instants are equal:</p>
  33.      * <ul>
  34.      *   <li>1977-01-01T00:00:32.184 TT</li>
  35.      *   <li>1977-01-01T00:00:32.184 TCG</li>
  36.      *   <li>1977-01-01T00:00:32.184 TCB</li>
  37.      *   <li>1977-01-01T00:00:00.000 TAI</li>
  38.      * </ul>
  39.      */
  40.     private static final AbsoluteDate REFERENCE_DATE =
  41.         new AbsoluteDate(1977, 01, 01, TimeScalesFactory.getTAI());

  42.     /** Barycentric dynamic time scale. */
  43.     private final TDBScale tdb;

  44.     /** Package private constructor for the factory.
  45.      * @param tdb Barycentric dynamic time scale
  46.      */
  47.     TCBScale(final TDBScale tdb) {
  48.         this.tdb = tdb;
  49.     }

  50.     /** {@inheritDoc} */
  51.     public double offsetFromTAI(final AbsoluteDate date) {
  52.         return tdb.offsetFromTAI(date) + LB_RATE * date.durationFrom(REFERENCE_DATE);
  53.     }

  54.     /** {@inheritDoc} */
  55.     public double offsetToTAI(final DateComponents date, final TimeComponents time) {
  56.         final AbsoluteDate reference = new AbsoluteDate(date, time, TimeScalesFactory.getTAI());
  57.         double offset = 0;
  58.         for (int i = 0; i < 3; i++) {
  59.             offset = -offsetFromTAI(reference.shiftedBy(offset));
  60.         }
  61.         return offset;
  62.     }

  63.     /** {@inheritDoc} */
  64.     public String getName() {
  65.         return "TCB";
  66.     }

  67.     /** {@inheritDoc} */
  68.     public String toString() {
  69.         return getName();
  70.     }

  71. }