1 /* Copyright 2002-2025 CS GROUP
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
18 package org.orekit.files.ccsds.ndm.odm.opm;
19
20 import java.util.Arrays;
21
22 import org.hipparchus.geometry.euclidean.threed.Vector3D;
23 import org.orekit.files.ccsds.definitions.FrameFacade;
24 import org.orekit.files.ccsds.section.CommentsContainer;
25 import org.orekit.time.AbsoluteDate;
26
27 /** Maneuver in an OPM file.
28 * <p>
29 * Beware that the Orekit getters and setters all rely on SI units. The parsers
30 * and writers take care of converting these SI units into CCSDS mandatory units.
31 * The {@link org.orekit.utils.units.Unit Unit} class provides useful
32 * {@link org.orekit.utils.units.Unit#fromSI(double) fromSi} and
33 * {@link org.orekit.utils.units.Unit#toSI(double) toSI} methods in case the callers
34 * already use CCSDS units instead of the API SI units. The general-purpose
35 * {@link org.orekit.utils.units.Unit Unit} class (without an 's') and the
36 * CCSDS-specific {@link org.orekit.files.ccsds.definitions.Units Units} class
37 * (with an 's') also provide some predefined units. These predefined units and the
38 * {@link org.orekit.utils.units.Unit#fromSI(double) fromSi} and
39 * {@link org.orekit.utils.units.Unit#toSI(double) toSI} conversion methods are indeed
40 * what the parsers and writers use for the conversions.
41 * </p>
42 * @author sports
43 * @since 6.1
44 */
45 public class Maneuver extends CommentsContainer {
46
47 /** Epoch ignition. */
48 private AbsoluteDate epochIgnition;
49
50 /** Coordinate system for velocity increment vector, for absolute frames. */
51 private FrameFacade referenceFrame;
52
53 /** Duration (value is 0 for impulsive maneuver). */
54 private double duration;
55
56 /** Mass change during maneuver (value is < 0). */
57 private double deltaMass;
58
59 /** Velocity increment. */
60 private final double[] dV;
61
62 /** Simple constructor.
63 */
64 public Maneuver() {
65 duration = Double.NaN;
66 deltaMass = Double.NaN;
67 dV = new double[3];
68 Arrays.fill(dV, Double.NaN);
69 }
70
71 /** {@inheritDoc} */
72 @Override
73 public void validate(final double version) {
74 super.validate(version);
75 checkNotNull(epochIgnition, ManeuverKey.MAN_EPOCH_IGNITION.name());
76 checkNotNull(referenceFrame, ManeuverKey.MAN_REF_FRAME.name());
77 checkNotNaN(duration, ManeuverKey.MAN_DURATION.name());
78 checkNotNaN(deltaMass, ManeuverKey.MAN_DELTA_MASS.name());
79 checkNotNaN(dV[0], ManeuverKey.MAN_DV_1.name());
80 checkNotNaN(dV[1], ManeuverKey.MAN_DV_2.name());
81 checkNotNaN(dV[2], ManeuverKey.MAN_DV_3.name());
82 }
83
84 /** Get epoch ignition.
85 * @return epoch ignition
86 */
87 public AbsoluteDate getEpochIgnition() {
88 return epochIgnition;
89 }
90
91 /** Set epoch ignition.
92 * @param epochIgnition epoch ignition
93 */
94 public void setEpochIgnition(final AbsoluteDate epochIgnition) {
95 this.epochIgnition = epochIgnition;
96 }
97
98 /** Get Coordinate system for velocity increment vector.
99 * @return coordinate system for velocity increment vector
100 */
101 public FrameFacade getReferenceFrame() {
102 return referenceFrame;
103 }
104
105 /** Set Coordinate system for velocity increment vector.
106 * @param referenceFrame coordinate system for velocity increment vector
107 */
108 public void setReferenceFrame(final FrameFacade referenceFrame) {
109 this.referenceFrame = referenceFrame;
110 }
111
112 /** Get duration (value is 0 for impulsive maneuver).
113 * @return duration (value is 0 for impulsive maneuver)
114 */
115 public double getDuration() {
116 return duration;
117 }
118
119 /** Set duration (value is 0 for impulsive maneuver).
120 * @param duration duration (value is 0 for impulsive maneuver)
121 */
122 public void setDuration(final double duration) {
123 this.duration = duration;
124 }
125
126 /** Get mass change during maneuver (value is < 0).
127 * @return mass change during maneuver (value is < 0)
128 */
129 public double getDeltaMass() {
130 return deltaMass;
131 }
132
133 /** Set mass change during maneuver (value is < 0).
134 * @param deltaMass mass change during maneuver (value is < 0)
135 */
136 public void setDeltaMass(final double deltaMass) {
137 this.deltaMass = deltaMass;
138 }
139
140 /** Get velocity increment.
141 * @return velocity increment
142 */
143 public Vector3D getDV() {
144 return new Vector3D(dV);
145 }
146
147 /** Set velocity increment component.
148 * @param i component index
149 * @param dVi velocity increment component
150 */
151 public void setDV(final int i, final double dVi) {
152 dV[i] = dVi;
153 }
154
155 /** Check if maneuver has been completed.
156 * @return true if maneuver has been completed
157 */
158 public boolean completed() {
159 return !(epochIgnition == null ||
160 referenceFrame == null ||
161 Double.isNaN(duration + deltaMass + dV[0] + dV[1] + dV[2]));
162 }
163
164 }