LocalOrbitalFrame.java

  1. /* Copyright 2002-2017 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.RealFieldElement;
  19. import org.orekit.errors.OrekitException;
  20. import org.orekit.time.AbsoluteDate;
  21. import org.orekit.time.FieldAbsoluteDate;
  22. import org.orekit.utils.PVCoordinatesProvider;

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

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

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

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

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

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

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

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

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

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

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

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

  98.     }

  99. }