1   /* Copyright 2002-2021 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;
19  
20  import org.orekit.files.ccsds.section.CommentsContainer;
21  import org.orekit.files.ccsds.section.Data;
22  import org.orekit.frames.Frame;
23  import org.orekit.orbits.KeplerianOrbit;
24  import org.orekit.orbits.PositionAngle;
25  import org.orekit.time.AbsoluteDate;
26  
27  /** Container for Keplerian elements.
28   * @author sports
29   * @since 6.1
30   */
31  public class KeplerianElements extends CommentsContainer implements Data {
32  
33      /** Epoch of state vector and optional Keplerian elements. */
34      private AbsoluteDate epoch;
35  
36      /** Orbit semi-major axis (m). */
37      private double a;
38  
39      /** Mean motion (the Keplerian Mean motion in rad/s).
40       * <p>
41       * Used in OMM instead of semi-major axis if MEAN_ELEMENT_THEORY = SGP/SGP4.
42       * </p>
43       */
44      private double meanMotion;
45  
46      /** Orbit eccentricity. */
47      private double e;
48  
49      /** Orbit inclination (rad). */
50      private double i;
51  
52      /** Orbit right ascension of ascending node (rad). */
53      private double raan;
54  
55      /** Orbit argument of pericenter (rad). */
56      private double pa;
57  
58      /** Orbit anomaly (rad). */
59      private double anomaly;
60  
61      /** Orbit anomaly type (mean or true). */
62      private PositionAngle anomalyType;
63  
64      /** Gravitational coefficient. */
65      private double mu;
66  
67      /** Simple constructor.
68       */
69      public KeplerianElements() {
70          a          = Double.NaN;
71          meanMotion =  Double.NaN;
72          e          = Double.NaN;
73          i          = Double.NaN;
74          raan       = Double.NaN;
75          pa         = Double.NaN;
76          anomaly    = Double.NaN;
77          mu         = Double.NaN;
78      }
79  
80      /** {@inheritDoc}
81       * <p>
82       * We check neither semi-major axis nor mean motion here,
83       * they must be checked separately in OPM and OMM parsers
84       * </p>
85       */
86      @Override
87      public void validate(final double version) {
88          super.validate(version);
89          checkNotNull(epoch,  StateVectorKey.EPOCH);
90          checkNotNaN(e,       KeplerianElementsKey.ECCENTRICITY);
91          checkNotNaN(i,       KeplerianElementsKey.INCLINATION);
92          checkNotNaN(raan,    KeplerianElementsKey.RA_OF_ASC_NODE);
93          checkNotNaN(pa,      KeplerianElementsKey.ARG_OF_PERICENTER);
94          checkNotNaN(anomaly, KeplerianElementsKey.MEAN_ANOMALY);
95      }
96  
97      /** Get epoch of state vector, Keplerian elements and covariance matrix data.
98       * @return epoch the epoch
99       */
100     public AbsoluteDate getEpoch() {
101         return epoch;
102     }
103 
104     /** Set epoch of state vector, Keplerian elements and covariance matrix data.
105      * @param epoch the epoch to be set
106      */
107     public void setEpoch(final AbsoluteDate epoch) {
108         refuseFurtherComments();
109         this.epoch = epoch;
110     }
111 
112     /** Get the orbit semi-major axis.
113      * @return the orbit semi-major axis
114      */
115     public double getA() {
116         return a;
117     }
118 
119     /** Set the orbit semi-major axis.
120      * @param a the semi-major axis to be set
121      */
122     public void setA(final double a) {
123         refuseFurtherComments();
124         this.a = a;
125     }
126 
127     /** Get the orbit mean motion.
128      * @return the orbit mean motion
129      */
130     public double getMeanMotion() {
131         return meanMotion;
132     }
133 
134     /** Set the orbit mean motion.
135      * @param motion the mean motion to be set
136      */
137     public void setMeanMotion(final double motion) {
138         this.meanMotion = motion;
139     }
140 
141     /** Get the orbit eccentricity.
142      * @return the orbit eccentricity
143      */
144     public double getE() {
145         return e;
146     }
147 
148     /** Set the orbit eccentricity.
149      * @param e the eccentricity to be set
150      */
151     public void setE(final double e) {
152         refuseFurtherComments();
153         this.e = e;
154     }
155 
156     /** Get the orbit inclination.
157      * @return the orbit inclination
158      */
159     public double getI() {
160         return i;
161     }
162 
163     /**Set the orbit inclination.
164      * @param i the inclination to be set
165      */
166     public void setI(final double i) {
167         refuseFurtherComments();
168         this.i = i;
169     }
170 
171     /** Get the orbit right ascension of ascending node.
172      * @return the orbit right ascension of ascending node
173      */
174     public double getRaan() {
175         return raan;
176     }
177 
178     /** Set the orbit right ascension of ascending node.
179      * @param raan the right ascension of ascending node to be set
180      */
181     public void setRaan(final double raan) {
182         refuseFurtherComments();
183         this.raan = raan;
184     }
185 
186     /** Get the orbit argument of pericenter.
187      * @return the orbit argument of pericenter
188      */
189     public double getPa() {
190         return pa;
191     }
192 
193     /** Set the orbit argument of pericenter.
194      * @param pa the argument of pericenter to be set
195      */
196     public void setPa(final double pa) {
197         refuseFurtherComments();
198         this.pa = pa;
199     }
200 
201     /** Get the orbit anomaly.
202      * @return the orbit anomaly
203      */
204     public double getAnomaly() {
205         return anomaly;
206     }
207 
208     /** Set the orbit anomaly.
209      * @param anomaly the anomaly to be set
210      */
211     public void setAnomaly(final double anomaly) {
212         refuseFurtherComments();
213         this.anomaly = anomaly;
214     }
215 
216     /** Get the type of anomaly (true or mean).
217      * @return the type of anomaly
218      */
219     public PositionAngle getAnomalyType() {
220         return anomalyType;
221     }
222 
223     /** Set the type of anomaly.
224      * @param anomalyType the type of anomaly to be set
225      */
226     public void setAnomalyType(final PositionAngle anomalyType) {
227         refuseFurtherComments();
228         this.anomalyType = anomalyType;
229     }
230 
231     /**
232      * Set the gravitational coefficient.
233      * @param mu the coefficient to be set
234      */
235     public void setMu(final double mu) {
236         refuseFurtherComments();
237         this.mu = mu;
238     }
239 
240     /**
241      * Get the gravitational coefficient.
242      * @return gravitational coefficient
243      */
244     public double getMu() {
245         return mu;
246     }
247 
248     /** Generate a keplerian orbit.
249      * @param frame inertial frame for orbit
250      * @return generated orbit
251      */
252     public KeplerianOrbit generateKeplerianOrbit(final Frame frame) {
253         return new KeplerianOrbit(a, e, i, pa, raan, anomaly, anomalyType, frame, epoch, mu);
254     }
255 
256 }