1   /* Copyright 2002-2025 Joseph Reed
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    * Joseph Reed 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.utils;
18  
19  import org.hipparchus.geometry.euclidean.threed.Vector3D;
20  import org.orekit.bodies.GeodeticPoint;
21  import org.orekit.bodies.OneAxisEllipsoid;
22  import org.orekit.frames.Frame;
23  import org.orekit.time.AbsoluteDate;
24  
25  /** Provider based on a single point.
26   *
27   * When {@link #getPVCoordinates(AbsoluteDate, Frame)} is called, the constant
28   * point will be translated to the destination frame and returned. This behavior is
29   * different than {@link AbsolutePVCoordinates#getPVCoordinates(AbsoluteDate, Frame)} (which
30   * uses {@link AbsolutePVCoordinates#shiftedBy(double) shiftedBy()} internally.). Use
31   * this class when no shifting should be performed (e.g. representing a fixed point on the ground).
32   *
33   * @author Joe Reed
34   * @since 11.3
35   */
36  public class ConstantPVCoordinatesProvider implements PVCoordinatesProvider {
37  
38      /** The position/velocity/acceleration point. */
39      private final PVCoordinates pva;
40  
41      /** The frame in which pva is defined. */
42      private final Frame sourceFrame;
43  
44      /** Create the PVCoordinatesProvider from a fixed point in a frame.
45       *
46       * @param pos the fixed position in the frame
47       * @param frame the frame in which {@code pva} is defined
48       */
49      public ConstantPVCoordinatesProvider(final Vector3D pos, final Frame frame) {
50          this(new PVCoordinates(pos), frame);
51      }
52  
53      /** Create a the provider from a fixed lat/lon/alt on a central body.
54       *
55       * This method is provided as convienience for
56       * {@code new ConstantPVCoordinatesProvider(body.transform(pos), body.getBodyFrame())}.
57       *
58       * @param pos the position relative to the ellipsoid's surface
59       * @param body the reference ellipsoid
60       */
61      public ConstantPVCoordinatesProvider(final GeodeticPoint pos, final OneAxisEllipsoid body) {
62          this(body.transform(pos), body.getBodyFrame());
63      }
64  
65      /** Create the PVCoordinatesProvider from a fixed point in a frame.
66       *
67       * @param pva the point in the frame
68       * @param frame the frame in which {@code pva} is defined
69       */
70      public ConstantPVCoordinatesProvider(final PVCoordinates pva, final Frame frame) {
71          this.pva = pva;
72          this.sourceFrame = frame;
73      }
74  
75      @Override
76      public Vector3D getPosition(final AbsoluteDate date, final Frame frame) {
77          return sourceFrame.getStaticTransformTo(frame, date).transformPosition(pva.getPosition());
78      }
79  
80      @Override
81      public TimeStampedPVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame) {
82          final PVCoordinates pv = sourceFrame.getTransformTo(frame, date).transformPVCoordinates(pva);
83  
84          return new TimeStampedPVCoordinates(date, pv);
85      }
86  }