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.definitions;
18  
19  import org.orekit.bodies.CelestialBody;
20  import org.orekit.frames.AngularTransformProvider;
21  import org.orekit.frames.Frame;
22  
23  /**
24   * A reference frame created from the {@code REF_FRAME} and {@code CENTER_NAME} is a CCSDS
25   * OPM, OMM, or OEM file.
26   *
27   * @author Evan Ward
28   */
29  public class ModifiedFrame extends Frame {
30  
31      /** Reference frame used to create this frame. */
32      private final CelestialBodyFrame refFrame;
33  
34      /** Value of the CENTER_NAME keyword in the ODM file used to create this frame. */
35      private final String centerName;
36  
37      /**
38       * Create a CCSDS reference frame that is centered on {@code body} and
39       * aligned with {@code frame}.
40       *
41       * <p>Callers should check that the requested frame is not already stored
42       * somewhere else. For example, Earth-centered ICRF is
43       * {@code Frames.getGCRF()}. {@link OrekitCcsdsFrameMapper} performs the
44       * checking for CCSDS frames that Orekit implements.
45       *
46       * @param frame      the existing frame that specifies the orientation.
47       * @param refFrame   the reference frame used to create {@code frame}.
48       * @param body       the origin.
49       * @param centerName the value of the {@code CENTER_NAME} key word used to
50       *                   create {@code body}.
51       * @see #ModifiedFrame(Frame, CelestialBodyFrame, CelestialBody, String,
52       * String)
53       */
54      public ModifiedFrame(final Frame frame,
55                           final CelestialBodyFrame refFrame,
56                           final CelestialBody body,
57                           final String centerName) {
58          this(frame, refFrame, body, centerName,
59                  body.getName() + "/" + frame.getName());
60      }
61  
62      /**
63       * Create a CCSDS reference frame that is centered on {@code body} and
64       * aligned with {@code frame}.
65       *
66       * <p>Callers should check that the requested frame is not already stored
67       * somewhere else. For example, Earth-centered ICRF is
68       * {@code Frames.getGCRF()}. {@link OrekitCcsdsFrameMapper} performs the
69       * checking for CCSDS frames that Orekit implements.
70       *
71       * @param frame      the existing frame that specifies the orientation.
72       * @param refFrame   the reference frame used to create {@code frame}.
73       * @param body       the origin.
74       * @param centerName the value of the {@code CENTER_NAME} key word used to
75       *                   create {@code body}.
76       * @param frameName  the name of this frame, returned by
77       *                   {@link #getName()}.
78       * @see #ModifiedFrame(Frame, CelestialBodyFrame, CelestialBody, String)
79       * @since 14.0
80       */
81      public ModifiedFrame(final Frame frame,
82                           final CelestialBodyFrame refFrame,
83                           final CelestialBody body,
84                           final String centerName,
85                           final String frameName) {
86          // unit tests reveal there is a tradeoff in translation vs. rotation
87          // error, but that the error is often lower when translation is
88          // performed first, then rotation.
89          super(body.getIcrfAlignedFrame(),
90                  new AngularTransformProvider(body.getIcrfAlignedFrame(), frame),
91                  frameName,
92                  frame.isPseudoInertial());
93          this.refFrame = refFrame;
94          this.centerName = centerName;
95      }
96  
97      /**
98       * Get the CCSDS reference frame.
99       *
100      * @return the reference frame used to create this frame.
101      */
102     public CelestialBodyFrame getRefFrame() {
103         return refFrame;
104     }
105 
106     /**
107      * Get the CCSDS center name.
108      *
109      * @return the value of the {@code CENTER_NAME} key word used to specify the origin of
110      * this frame.
111      */
112     public String getCenterName() {
113         return centerName;
114     }
115 
116 }