ExtendedPositionProviderAdapter.java

  1. /* Copyright 2022-2025 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.FieldStaticTransform;
  20. import org.orekit.frames.FieldTransform;
  21. import org.orekit.frames.Frame;
  22. import org.orekit.frames.StaticTransform;
  23. import org.orekit.frames.Transform;
  24. import org.orekit.frames.TransformProvider;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.time.FieldAbsoluteDate;

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

  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 ExtendedPositionProviderAdapter(final Frame parent,
  46.                                            final ExtendedPositionProvider provider,
  47.                                            final String name) {
  48.         super(parent, new TransformProvider() {

  49.             /** {@inheritDoc} */
  50.             @Override
  51.             public StaticTransform getStaticTransform(final AbsoluteDate date) {
  52.                 return StaticTransform.of(date, provider.getPosition(date, parent).negate());
  53.             }

  54.             /** {@inheritDoc} */
  55.             @Override
  56.             public <T extends CalculusFieldElement<T>> FieldStaticTransform<T> getStaticTransform(final FieldAbsoluteDate<T> date) {
  57.                 return FieldStaticTransform.of(date, provider.getPosition(date, parent).negate());
  58.             }

  59.             /** {@inheritDoc} */
  60.             @Override
  61.             public Transform getTransform(final AbsoluteDate date) {
  62.                 return new Transform(date, provider.getPVCoordinates(date, parent).negate());
  63.             }

  64.             /** {@inheritDoc} */
  65.             @Override
  66.             public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
  67.                 return new FieldTransform<>(date, provider.getPVCoordinates(date, parent).negate());
  68.             }

  69.         }, name);
  70.     }

  71. }