1   /* Copyright 2002-2024 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.estimation.measurements.modifiers;
18  
19  import org.hipparchus.geometry.euclidean.threed.Vector3D;
20  import org.orekit.estimation.measurements.EstimatedMeasurementBase;
21  import org.orekit.utils.Constants;
22  import org.orekit.utils.TimeStampedPVCoordinates;
23  
24  /** Class modifying theoretical measurements with relativistic clock correction.
25   * <p>
26   * Relativistic clock correction is caused by the motion of the satellite as well as
27   * the change in the gravitational potential
28   * </p>
29   * @author Bryan Cazabonne
30   * @since 10.3
31   *
32   * @see "Teunissen, Peter, and Oliver Montenbruck, eds. Springer handbook of global navigation
33   * satellite systems. Chapter 19.2. Springer, 2017."
34   */
35  public class AbstractRelativisticClockModifier {
36  
37      /** Relativistic effect scale factor. */
38      private final double s;
39  
40      /** Simple constructor. */
41      public AbstractRelativisticClockModifier() {
42          this.s = -2.0 / (Constants.SPEED_OF_LIGHT * Constants.SPEED_OF_LIGHT);
43      }
44  
45      /** Computes the relativistic clock correction.
46       * @param estimated estimated measurement
47       * @return the relativistic clock correction in seconds
48       */
49      protected double relativisticCorrection(final EstimatedMeasurementBase<?> estimated) {
50          // Participants
51          final TimeStampedPVCoordinates[] pv = estimated.getParticipants();
52          // Relativistic clock correction taking into account two-ways measurements
53          return pv.length < 3 ?
54                 s * (dotProduct(pv[0]) - dotProduct(pv[1])) :
55                 s * (dotProduct(pv[1]) - dotProduct(pv[2]));
56      }
57  
58      /** Get the scale factor used to compute relativistic effect.
59       * @return the scale factor
60       */
61      protected double getScaleFactor() {
62          return s;
63      }
64  
65      /** Compute the dot-product of position and velocity vectors.
66       * @param pv satellite coordinates
67       * @return the dot-product of position and velocity vectors
68       */
69      private static double dotProduct(final TimeStampedPVCoordinates pv) {
70          return Vector3D.dotProduct(pv.getPosition(), pv.getVelocity());
71      }
72  
73  }