CcsdsModifiedFrame.java

  1. /* Contributed in the public domain.
  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.files.ccsds;

  18. import org.hipparchus.RealFieldElement;
  19. import org.orekit.bodies.CelestialBody;
  20. import org.orekit.errors.OrekitException;
  21. import org.orekit.frames.FieldTransform;
  22. import org.orekit.frames.Frame;
  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. /**
  28.  * A reference frame created from the {@code REF_FRAME} and {@code CENTER_NAME} is a CCSDS
  29.  * OPM, OMM, or OEM file.
  30.  *
  31.  * @author Evan Ward
  32.  */
  33. public class CcsdsModifiedFrame extends Frame {

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

  36.     /** Value of the REF_FRAME keyword in the ODM file used to create this frame. */
  37.     private final String refFrame;

  38.     /** Value of the CENTER_NAME keyword in the ODM file used to create this frame. */
  39.     private final String centerName;

  40.     /**
  41.      * Create a CCSDS reference frame by changing the origin of an existing frame.
  42.      *
  43.      * @param frame      the existing frame that specifies the orientation.
  44.      * @param refFrame   the value of the {@code REF_FRAME} key word used to create {@code
  45.      *                   frame}.
  46.      * @param body       the new origin.
  47.      * @param centerName the value of the {@code CENTER_NAME} key word used to create
  48.      *                   {@code body}.
  49.      */
  50.     CcsdsModifiedFrame(final Frame frame,
  51.                        final String refFrame,
  52.                        final CelestialBody body,
  53.                        final String centerName) {
  54.         super(
  55.                 frame,
  56.                 new OriginTransformProvider(body, frame),
  57.                 body.getName() + "/" + frame.getName(),
  58.                 frame.isPseudoInertial());
  59.         this.refFrame = refFrame;
  60.         this.centerName = centerName;
  61.     }

  62.     /**
  63.      * Get the name of the CCSDS reference frame.
  64.      *
  65.      * @return the value of the {@code REF_FRAME} keyword used to specify the orientation
  66.      * of this frame.
  67.      */
  68.     public String getRefFrame() {
  69.         return refFrame;
  70.     }

  71.     /**
  72.      * Get the CCSDS center name.
  73.      *
  74.      * @return the value of the {@code CENTER_NAME} key word used to specify the origin of
  75.      * this frame.
  76.      */
  77.     public String getCenterName() {
  78.         return centerName;
  79.     }

  80.     /** Transform provider for {@link CcsdsModifiedFrame}. */
  81.     private static class OriginTransformProvider implements TransformProvider {

  82.         /** Serializable UID. */
  83.         private static final long serialVersionUID = 20170619L;

  84.         /** The new origin. */
  85.         private final CelestialBody body;

  86.         /** The original frame, specifying the orientation. */
  87.         private final Frame frame;

  88.         /**
  89.          * Create a transform provider to change the origin of an existing frame.
  90.          *
  91.          * @param frame the existing frame that specifies the orientation.
  92.          * @param body  the new origin.
  93.          */
  94.         OriginTransformProvider(final CelestialBody body, final Frame frame) {
  95.             this.body = body;
  96.             this.frame = frame;
  97.         }

  98.         @Override
  99.         public Transform getTransform(final AbsoluteDate date)
  100.                 throws OrekitException {
  101.             return new Transform(date, body.getPVCoordinates(date, frame));
  102.         }

  103.         @Override
  104.         public <T extends RealFieldElement<T>> FieldTransform<T> getTransform(
  105.                 final FieldAbsoluteDate<T> date) throws OrekitException {
  106.             return new FieldTransform<>(
  107.                     date,
  108.                     body.getPVCoordinates(date, frame));
  109.         }

  110.     }

  111. }