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
19 import org.hipparchus.RealFieldElement;
20 import org.orekit.bodies.CelestialBody;
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 /**
29 * A reference frame created from the {@code REF_FRAME} and {@code CENTER_NAME} is a CCSDS
30 * OPM, OMM, or OEM file.
31 *
32 * @author Evan Ward
33 */
34 public class CcsdsModifiedFrame extends Frame {
35
36 /** Serializable UID. */
37 private static final long serialVersionUID = 20170619L;
38
39 /** Value of the REF_FRAME keyword in the ODM file used to create this frame. */
40 private final String refFrame;
41
42 /** Value of the CENTER_NAME keyword in the ODM file used to create this frame. */
43 private final String centerName;
44
45 /**
46 * Create a CCSDS reference frame by changing the origin of an existing frame.
47 *
48 * @param frame the existing frame that specifies the orientation.
49 * @param refFrame the value of the {@code REF_FRAME} key word used to create {@code
50 * frame}.
51 * @param body the new origin.
52 * @param centerName the value of the {@code CENTER_NAME} key word used to create
53 * {@code body}.
54 */
55 CcsdsModifiedFrame(final Frame frame,
56 final String refFrame,
57 final CelestialBody body,
58 final String centerName) {
59 super(
60 frame,
61 new OriginTransformProvider(body, frame),
62 body.getName() + "/" + frame.getName(),
63 frame.isPseudoInertial());
64 this.refFrame = refFrame;
65 this.centerName = centerName;
66 }
67
68 /**
69 * Get the name of the CCSDS reference frame.
70 *
71 * @return the value of the {@code REF_FRAME} keyword used to specify the orientation
72 * of this frame.
73 */
74 public String getRefFrame() {
75 return refFrame;
76 }
77
78 /**
79 * Get the CCSDS center name.
80 *
81 * @return the value of the {@code CENTER_NAME} key word used to specify the origin of
82 * this frame.
83 */
84 public String getCenterName() {
85 return centerName;
86 }
87
88 /** Transform provider for {@link CcsdsModifiedFrame}. */
89 private static class OriginTransformProvider implements TransformProvider {
90
91 /** Serializable UID. */
92 private static final long serialVersionUID = 20170619L;
93
94 /** The new origin. */
95 private final CelestialBody body;
96
97 /** The original frame, specifying the orientation. */
98 private final Frame frame;
99
100 /**
101 * Create a transform provider to change the origin of an existing frame.
102 *
103 * @param frame the existing frame that specifies the orientation.
104 * @param body the new origin.
105 */
106 OriginTransformProvider(final CelestialBody body, final Frame frame) {
107 this.body = body;
108 this.frame = frame;
109 }
110
111 @Override
112 public Transform getTransform(final AbsoluteDate date) {
113 return new Transform(date, body.getPVCoordinates(date, frame).negate());
114 }
115
116 @Override
117 public <T extends RealFieldElement<T>> FieldTransform<T> getTransform(
118 final FieldAbsoluteDate<T> date) {
119 return new FieldTransform<>(
120 date,
121 body.getPVCoordinates(date, frame).negate());
122 }
123
124 }
125
126 }