ConstantPVCoordinatesProvider.java

  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. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  19. import org.orekit.bodies.GeodeticPoint;
  20. import org.orekit.bodies.OneAxisEllipsoid;
  21. import org.orekit.frames.Frame;
  22. import org.orekit.time.AbsoluteDate;

  23. /** Provider based on a single point.
  24.  *
  25.  * When {@link #getPVCoordinates(AbsoluteDate, Frame)} is called, the constant
  26.  * point will be translated to the destination frame and returned. This behavior is
  27.  * different than {@link AbsolutePVCoordinates#getPVCoordinates(AbsoluteDate, Frame)} (which
  28.  * uses {@link AbsolutePVCoordinates#shiftedBy(double) shiftedBy()} internally.). Use
  29.  * this class when no shifting should be performed (e.g. representing a fixed point on the ground).
  30.  *
  31.  * @author Joe Reed
  32.  * @since 11.3
  33.  */
  34. public class ConstantPVCoordinatesProvider implements PVCoordinatesProvider {

  35.     /** The position/velocity/acceleration point. */
  36.     private final PVCoordinates pva;

  37.     /** The frame in which pva is defined. */
  38.     private final Frame sourceFrame;

  39.     /** Create the PVCoordinatesProvider from a fixed point in a frame.
  40.      *
  41.      * @param pos the fixed position in the frame
  42.      * @param frame the frame in which {@code pva} is defined
  43.      */
  44.     public ConstantPVCoordinatesProvider(final Vector3D pos, final Frame frame) {
  45.         this(new PVCoordinates(pos), frame);
  46.     }

  47.     /** Create a the provider from a fixed lat/lon/alt on a central body.
  48.      *
  49.      * This method is provided as convienience for
  50.      * {@code new ConstantPVCoordinatesProvider(body.transform(pos), body.getBodyFrame())}.
  51.      *
  52.      * @param pos the position relative to the ellipsoid's surface
  53.      * @param body the reference ellipsoid
  54.      */
  55.     public ConstantPVCoordinatesProvider(final GeodeticPoint pos, final OneAxisEllipsoid body) {
  56.         this(body.transform(pos), body.getBodyFrame());
  57.     }

  58.     /** Create the PVCoordinatesProvider from a fixed point in a frame.
  59.      *
  60.      * @param pva the point in the frame
  61.      * @param frame the frame in which {@code pva} is defined
  62.      */
  63.     public ConstantPVCoordinatesProvider(final PVCoordinates pva, final Frame frame) {
  64.         this.pva = pva;
  65.         this.sourceFrame = frame;
  66.     }

  67.     @Override
  68.     public Vector3D getPosition(final AbsoluteDate date, final Frame frame) {
  69.         return sourceFrame.getStaticTransformTo(frame, date).transformPosition(pva.getPosition());
  70.     }

  71.     @Override
  72.     public TimeStampedPVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame) {
  73.         final PVCoordinates pv = sourceFrame.getTransformTo(frame, date).transformPVCoordinates(pva);

  74.         return new TimeStampedPVCoordinates(date, pv);
  75.     }
  76. }