ExtendedPVCoordinatesProviderAdapter.java

  1. /* Copyright 2002-2024 Luc Maisonobe
  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.utils;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.orekit.frames.FieldTransform;
  20. import org.orekit.frames.Frame;
  21. import org.orekit.frames.Transform;
  22. import org.orekit.frames.TransformProvider;
  23. import org.orekit.time.AbsoluteDate;
  24. import org.orekit.time.FieldAbsoluteDate;

  25. /** Adapter from {@link ExtendedPVCoordinatesProvider} to {@link TransformProvider}.
  26.  * <p>
  27.  * The transform provider is a simple translation from a defining frame such
  28.  * that the origin of the transformed frame corresponds to the moving point.
  29.  * </p>
  30.  * <p>
  31.  * This class is roughly the inverse of {@link FrameAdapter}
  32.  * </p>
  33.  * @see FrameAdapter
  34.  * @since 12.0
  35.  * @author Luc Maisonobe
  36.  */
  37. public class ExtendedPVCoordinatesProviderAdapter extends Frame {

  38.     /** Serializable UID. */
  39.     private static final long serialVersionUID = 20221215L;

  40.     /** Simple constructor.
  41.      * @param parent parent frame (must be non-null)
  42.      * @param provider coordinates provider defining the position of origin of the transformed frame
  43.      * @param name name of the frame
  44.      */
  45.     public ExtendedPVCoordinatesProviderAdapter(final Frame parent,
  46.                                                 final ExtendedPVCoordinatesProvider provider,
  47.                                                 final String name) {
  48.         super(parent, new TransformProvider() {

  49.             /** Serializable UID. */
  50.             private static final long serialVersionUID = 20221215L;

  51.             /** {@inheritDoc} */
  52.             @Override
  53.             public Transform getTransform(final AbsoluteDate date) {
  54.                 return new Transform(date, provider.getPVCoordinates(date, parent).negate());
  55.             }

  56.             /** {@inheritDoc} */
  57.             @Override
  58.             public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
  59.                 return new FieldTransform<>(date, provider.getPVCoordinates(date, parent).negate());
  60.             }

  61.         }, name);
  62.     }

  63. }