1   /* Copyright 2002-2025 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      /** Get the name of the effect modifying the measurement.
46       * @return name of the effect modifying the measurement
47       * @since 13.0
48       */
49      public String getEffectName() {
50          return "clock relativity";
51      }
52  
53      /** Computes the relativistic clock correction.
54       * @param estimated estimated measurement
55       * @return the relativistic clock correction in seconds
56       */
57      protected double relativisticCorrection(final EstimatedMeasurementBase<?> estimated) {
58          // Participants
59          final TimeStampedPVCoordinates[] pv = estimated.getParticipants();
60          // Relativistic clock correction taking into account two-ways measurements
61          return pv.length < 3 ?
62                 s * (dotProduct(pv[0]) - dotProduct(pv[1])) :
63                 s * (dotProduct(pv[1]) - dotProduct(pv[2]));
64      }
65  
66      /** Get the scale factor used to compute relativistic effect.
67       * @return the scale factor
68       */
69      protected double getScaleFactor() {
70          return s;
71      }
72  
73      /** Compute the dot-product of position and velocity vectors.
74       * @param pv satellite coordinates
75       * @return the dot-product of position and velocity vectors
76       */
77      private static double dotProduct(final TimeStampedPVCoordinates pv) {
78          return Vector3D.dotProduct(pv.getPosition(), pv.getVelocity());
79      }
80  
81  }