LocalOrbitalFrame.java

  1. /* Copyright 2002-2022 CS GROUP
  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.frames;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.orekit.time.AbsoluteDate;
  20. import org.orekit.time.FieldAbsoluteDate;
  21. import org.orekit.utils.PVCoordinatesProvider;

  22. /** Class for frames moving with an orbiting satellite.
  23.  *
  24.  * <p>There are several local orbital frames available. They are specified
  25.  * by the {@link LOFType} enumerate.</p>
  26.  *
  27.  * <p> Do not use the {@link #getTransformTo(Frame, FieldAbsoluteDate)} method as it is
  28.  * not implemented.
  29.  *
  30.  * @author Luc Maisonobe
  31.  * @see org.orekit.propagation.SpacecraftState#toTransform()
  32.  */
  33. public class LocalOrbitalFrame extends Frame {

  34.     /** Serializable UID. */
  35.     private static final long serialVersionUID = -4469440345574964950L;

  36.     /** Build a new instance.
  37.      *
  38.      * <p> It is highly recommended that {@code provider} use an analytic formulation and
  39.      * not numerical integration as large integration errors may result from many short
  40.      * propagations.
  41.      *
  42.      * @param parent parent frame (must be non-null)
  43.      * @param type frame type
  44.      * @param provider provider used to compute frame motion.
  45.      * @param name name of the frame
  46.      * @exception IllegalArgumentException if the parent frame is null
  47.      */
  48.     public LocalOrbitalFrame(final Frame parent, final LOFType type,
  49.                              final PVCoordinatesProvider provider,
  50.                              final String name)
  51.         throws IllegalArgumentException {
  52.         super(parent, new LocalProvider(type, provider, parent, name), name, false);
  53.     }

  54.     /** Local provider for transforms. */
  55.     private static class LocalProvider implements TransformProvider {

  56.         /** Serializable UID. */
  57.         private static final long serialVersionUID = 20170421L;

  58.         /** Frame type. */
  59.         private final LOFType type;

  60.         /** Provider used to compute frame motion. */
  61.         private final PVCoordinatesProvider provider;

  62.         /** Reference frame. */
  63.         private final Frame reference;

  64.         /** Name of the frame. */
  65.         private final String name;

  66.         /** Simple constructor.
  67.          * @param type frame type
  68.          * @param provider provider used to compute frame motion
  69.          * @param reference reference frame
  70.          * @param name name of the frame
  71.          */
  72.         LocalProvider(final LOFType type, final PVCoordinatesProvider provider,
  73.                       final Frame reference, final String name) {
  74.             this.type           = type;
  75.             this.provider       = provider;
  76.             this.reference      = reference;
  77.             this.name           = name;
  78.         }

  79.         /** {@inheritDoc} */
  80.         public Transform getTransform(final AbsoluteDate date) {
  81.             return type.transformFromInertial(date, provider.getPVCoordinates(date, reference));
  82.         }

  83.         /**
  84.          * This method is not implemented.
  85.          *
  86.          * <p> {@inheritDoc}
  87.          *
  88.          * @throws UnsupportedOperationException always.
  89.          */
  90.         public <T extends CalculusFieldElement<T>> FieldTransform<T> getTransform(
  91.                 final FieldAbsoluteDate<T> date) throws UnsupportedOperationException {
  92.             throw new UnsupportedOperationException(
  93.                     "FieldTransforms are not supported for a LocalOrbitalFrame: " + name +
  94.                             ". Please contact orekit-developers@orekit.org if you " +
  95.                             "would like to add this feature.");
  96.         }

  97.     }

  98. }