1   /* Copyright 2002-2026 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(dV[0],           ManeuverKey.MAN_DV_1.name());
78          checkNotNaN(dV[1],           ManeuverKey.MAN_DV_2.name());
79          checkNotNaN(dV[2],           ManeuverKey.MAN_DV_3.name());
80      }
81  
82      /** Get epoch ignition.
83       * @return epoch ignition
84       */
85      public AbsoluteDate getEpochIgnition() {
86          return epochIgnition;
87      }
88  
89      /** Set epoch ignition.
90       * @param epochIgnition epoch ignition
91       */
92      public void setEpochIgnition(final AbsoluteDate epochIgnition) {
93          this.epochIgnition = epochIgnition;
94      }
95  
96      /** Get Coordinate system for velocity increment vector.
97       * @return coordinate system for velocity increment vector
98       */
99      public FrameFacade getReferenceFrame() {
100         return referenceFrame;
101     }
102 
103     /** Set Coordinate system for velocity increment vector.
104      * @param referenceFrame coordinate system for velocity increment vector
105      */
106     public void setReferenceFrame(final FrameFacade referenceFrame) {
107         this.referenceFrame = referenceFrame;
108     }
109 
110     /** Get duration (value is 0 for impulsive maneuver).
111      * @return duration (value is 0 for impulsive maneuver)
112      */
113     public double getDuration() {
114         return duration;
115     }
116 
117     /** Set duration (value is 0 for impulsive maneuver).
118      * @param duration duration (value is 0 for impulsive maneuver)
119      */
120     public void setDuration(final double duration) {
121         this.duration = duration;
122     }
123 
124     /** Get mass change during maneuver (value is &lt; 0).
125      * @return mass change during maneuver (value is &lt; 0)
126      */
127     public double getDeltaMass() {
128         return deltaMass;
129     }
130 
131     /** Set mass change during maneuver (value is &lt; 0).
132      * @param deltaMass mass change during maneuver (value is &lt; 0)
133      */
134     public void setDeltaMass(final double deltaMass) {
135         this.deltaMass = deltaMass;
136     }
137 
138     /** Get velocity increment.
139      * @return velocity increment
140      */
141     public Vector3D getDV() {
142         return new Vector3D(dV);
143     }
144 
145     /** Set velocity increment component.
146      * @param i component index
147      * @param dVi velocity increment component
148      */
149     public void setDV(final int i, final double dVi) {
150         dV[i] = dVi;
151     }
152 
153     /** Check if maneuver has been completed.
154      * @return true if maneuver has been completed
155      */
156     public boolean completed() {
157         return !(epochIgnition == null ||
158                  referenceFrame == null ||
159                  Double.isNaN(dV[0] + dV[1] + dV[2]));
160     }
161 
162 }