1   /* Copyright 2022-2025 Thales Alenia Space
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  
18  package org.orekit.time;
19  
20  import org.junit.jupiter.api.Assertions;
21  import org.junit.jupiter.api.Test;
22  
23  import java.util.Arrays;
24  
25  class ClockOffsetHermiteInterpolatorTest {
26  
27      @Test
28      void testNoRate() {
29          final AbsoluteDate t0 = AbsoluteDate.GALILEO_EPOCH;
30          final ClockOffsetHermiteInterpolator interpolator = new ClockOffsetHermiteInterpolator(4);
31          ClockOffset interpolated =
32              interpolator.interpolate(t0.shiftedBy(2.5),
33                                       Arrays.asList(new ClockOffset(t0.shiftedBy(0),  0.0, Double.NaN, Double.NaN),
34                                                     new ClockOffset(t0.shiftedBy(1),  1.0, Double.NaN, Double.NaN),
35                                                     new ClockOffset(t0.shiftedBy(2),  4.0, Double.NaN, Double.NaN),
36                                                     new ClockOffset(t0.shiftedBy(3),  9.0, Double.NaN, Double.NaN),
37                                                     new ClockOffset(t0.shiftedBy(4), 16.0, Double.NaN, Double.NaN),
38                                                     new ClockOffset(t0.shiftedBy(5), 25.0, Double.NaN, Double.NaN)));
39          Assertions.assertEquals(6.25, interpolated.getOffset(),       1.0e-15);
40          Assertions.assertEquals(5.00, interpolated.getRate(),         1.0e-15);
41          Assertions.assertEquals(2.00, interpolated.getAcceleration(), 1.0e-15);
42      }
43  
44      @Test
45      void testNoAcceleration() {
46          final AbsoluteDate t0 = AbsoluteDate.GALILEO_EPOCH;
47          final ClockOffsetHermiteInterpolator interpolator = new ClockOffsetHermiteInterpolator(4);
48          ClockOffset interpolated =
49              interpolator.interpolate(t0.shiftedBy(2.5),
50                                       Arrays.asList(new ClockOffset(t0.shiftedBy(0),  0.0,  0.0, Double.NaN),
51                                                     new ClockOffset(t0.shiftedBy(1),  1.0,  2.0, Double.NaN),
52                                                     new ClockOffset(t0.shiftedBy(2),  4.0,  4.0, Double.NaN),
53                                                     new ClockOffset(t0.shiftedBy(3),  9.0,  6.0, Double.NaN),
54                                                     new ClockOffset(t0.shiftedBy(4), 16.0,  8.0, Double.NaN),
55                                                     new ClockOffset(t0.shiftedBy(5), 25.0, 10.0, Double.NaN)));
56          Assertions.assertEquals(6.25, interpolated.getOffset(),       1.0e-15);
57          Assertions.assertEquals(5.00, interpolated.getRate(),         1.0e-15);
58          Assertions.assertEquals(2.00, interpolated.getAcceleration(), 1.0e-15);
59      }
60  
61      @Test
62      void testComplete() {
63          final AbsoluteDate t0 = AbsoluteDate.GALILEO_EPOCH;
64          final ClockOffsetHermiteInterpolator interpolator = new ClockOffsetHermiteInterpolator(4);
65          ClockOffset interpolated =
66              interpolator.interpolate(t0.shiftedBy(2.5),
67                                       Arrays.asList(new ClockOffset(t0.shiftedBy(0),  0.0,  0.0, 2.0),
68                                                     new ClockOffset(t0.shiftedBy(1),  1.0,  2.0, 2.0),
69                                                     new ClockOffset(t0.shiftedBy(2),  4.0,  4.0, 2.0),
70                                                     new ClockOffset(t0.shiftedBy(3),  9.0,  6.0, 2.0),
71                                                     new ClockOffset(t0.shiftedBy(4), 16.0,  8.0, 2.0),
72                                                     new ClockOffset(t0.shiftedBy(5), 25.0, 10.0, 2.0)));
73          Assertions.assertEquals(6.25, interpolated.getOffset(),       1.0e-15);
74          Assertions.assertEquals(5.00, interpolated.getRate(),         1.0e-15);
75          Assertions.assertEquals(2.00, interpolated.getAcceleration(), 1.0e-15);
76      }
77  
78  }