1   /* Copyright 2022-2025 Romain Serra
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.utils;
19  
20  import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
21  import org.hipparchus.geometry.euclidean.threed.Vector3D;
22  import org.hipparchus.util.Binary64;
23  import org.hipparchus.util.Binary64Field;
24  import org.junit.jupiter.api.Test;
25  import org.orekit.TestUtils;
26  import org.orekit.frames.Frame;
27  import org.orekit.frames.FramesFactory;
28  import org.orekit.orbits.FieldCartesianOrbit;
29  import org.orekit.orbits.FieldOrbit;
30  import org.orekit.orbits.Orbit;
31  import org.orekit.time.AbsoluteDate;
32  import org.orekit.time.FieldAbsoluteDate;
33  
34  import static org.junit.jupiter.api.Assertions.assertEquals;
35  
36  class FieldShiftingPVCoordinatesProviderTest {
37  
38      @Test
39      void testGetPosition() {
40          // GIVEN
41          final Orbit orbit = TestUtils.getDefaultOrbit(AbsoluteDate.ARBITRARY_EPOCH);
42          final Binary64Field field = Binary64Field.getInstance();
43          final FieldOrbit<Binary64> fieldOrbit = new FieldCartesianOrbit<>(field, orbit);
44          final TimeStampedFieldPVCoordinates<Binary64> pvCoordinates = fieldOrbit.getPVCoordinates();
45          final FieldShiftingPVCoordinatesProvider<Binary64> pvCoordinatesProvider = new FieldShiftingPVCoordinatesProvider<>(pvCoordinates,
46                  orbit.getFrame());
47          final Frame frame = FramesFactory.getEME2000();
48          final FieldAbsoluteDate<Binary64> shiftedDate = fieldOrbit.getDate().shiftedBy(1000);
49          // WHEN
50          final FieldVector3D<Binary64> position = pvCoordinatesProvider.getPosition(shiftedDate, frame);
51          // THEN
52          final FieldPVCoordinates<Binary64> shiftedPV = pvCoordinatesProvider.getPVCoordinates(shiftedDate, frame);
53          final FieldVector3D<Binary64> expectedPosition = shiftedPV.getPosition();
54          final double tolerance = 1e-9;
55          assertEquals(expectedPosition.getX().getReal(), position.getX().getReal(), tolerance);
56          assertEquals(expectedPosition.getY().getReal(), position.getY().getReal(), tolerance);
57          assertEquals(expectedPosition.getZ().getReal(), position.getZ().getReal(), tolerance);
58      }
59  }