CcsdsModifiedFrame.java

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

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

  26. /**
  27.  * A reference frame created from the {@code REF_FRAME} and {@code CENTER_NAME} is a CCSDS
  28.  * OPM, OMM, or OEM file.
  29.  *
  30.  * @author Evan Ward
  31.  */
  32. public class CcsdsModifiedFrame extends Frame {

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

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

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

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

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

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

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

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

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

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

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

  97.         @Override
  98.         public Transform getTransform(final AbsoluteDate date) {
  99.             return new Transform(date, body.getPVCoordinates(date, frame).negate());
  100.         }

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

  108.     }

  109. }