1   /* Copyright 2002-2013 CS Systèmes d'Information
2    * Licensed to CS Systèmes d'Information (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.propagation.semianalytical.dsst.utilities;
18  
19  import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
20  import org.apache.commons.math3.util.FastMath;
21  import org.apache.commons.math3.util.MathUtils;
22  import org.orekit.frames.Frame;
23  import org.orekit.orbits.Orbit;
24  import org.orekit.time.AbsoluteDate;
25  
26  
27  /** Container class for common parameters used by all DSST forces.
28   *  <p>
29   *  Most of them are defined in Danielson paper at § 2.1.
30   *  </p>
31   *  @author Pascal Parraud
32   */
33  public class AuxiliaryElements {
34  
35      /** Orbit date. */
36      private final AbsoluteDate date;
37  
38      /** Orbit frame. */
39      private final Frame frame;
40  
41      /** Central body attraction coefficient. */
42      private final double mu;
43  
44      /** Eccentricity. */
45      private final double ecc;
46  
47      /** Keplerian mean motion. */
48      private final double n;
49  
50      /** Keplerian period. */
51      private final double period;
52  
53      /** Semi-major axis. */
54      private final double sma;
55  
56      /** x component of eccentricity vector. */
57      private final double k;
58  
59      /** y component of eccentricity vector. */
60      private final double h;
61  
62      /** x component of inclination vector. */
63      private final double q;
64  
65      /** y component of inclination vector. */
66      private final double p;
67  
68      /** Mean longitude. */
69      private final double lm;
70  
71      /** Retrograde factor I.
72       *  <p>
73       *  DSST model needs equinoctial orbit as internal representation.
74       *  Classical equinoctial elements have discontinuities when inclination
75       *  is close to zero. In this representation, I = +1. <br>
76       *  To avoid this discontinuity, another representation exists and equinoctial
77       *  elements can be expressed in a different way, called "retrograde" orbit.
78       *  This implies I = -1. <br>
79       *  As Orekit doesn't implement the retrograde orbit, I is always set to +1.
80       *  But for the sake of consistency with the theory, the retrograde factor
81       *  has been kept in the formulas.
82       *  </p>
83       */
84      private final int    I;
85  
86      /** A = sqrt(&mu; * a). */
87      private final double A;
88  
89      /** B = sqrt(1 - h<sup>2</sup> - k<sup>2</sup>). */
90      private final double B;
91  
92      /** C = 1 + p<sup>2</sup> + q<sup>2</sup>. */
93      private final double C;
94  
95      /** Equinoctial frame f vector. */
96      private final Vector3D f;
97  
98      /** Equinoctial frame g vector. */
99      private final Vector3D g;
100 
101     /** Equinoctial frame w vector. */
102     private final Vector3D w;
103 
104     /** Direction cosine &alpha;. */
105     private final double alpha;
106 
107     /** Direction cosine &beta;. */
108     private final double beta;
109 
110     /** Direction cosine &gamma;. */
111     private final double gamma;
112 
113     /** Simple constructor.
114      * @param orbit related mean orbit for auxiliary elements
115      * @param retrogradeFactor retrograde factor I [Eq. 2.1.2-(2)]
116      */
117     public AuxiliaryElements(final Orbit orbit, final int retrogradeFactor) {
118         // Date of the orbit
119         date = orbit.getDate();
120 
121         // Orbit definition frame
122         frame = orbit.getFrame();
123 
124         // Central body attraction coefficient
125         mu = orbit.getMu();
126 
127         // Eccentricity
128         ecc = orbit.getE();
129 
130         // Keplerian mean motion
131         n = orbit.getKeplerianMeanMotion();
132 
133         // Keplerian period
134         period = orbit.getKeplerianPeriod();
135 
136         // Equinoctial elements [Eq. 2.1.2-(1)]
137         sma = orbit.getA();
138         k   = orbit.getEquinoctialEx();
139         h   = orbit.getEquinoctialEy();
140         q   = orbit.getHx();
141         p   = orbit.getHy();
142         lm  = MathUtils.normalizeAngle(orbit.getLM(), FastMath.PI);
143 
144         // Retrograde factor [Eq. 2.1.2-(2)]
145         I = retrogradeFactor;
146 
147         final double k2 = k * k;
148         final double h2 = h * h;
149         final double q2 = q * q;
150         final double p2 = p * p;
151 
152         // A, B, C parameters [Eq. 2.1.6-(1)]
153         A = FastMath.sqrt(mu * sma);
154         B = FastMath.sqrt(1 - k2 - h2);
155         C = 1 + q2 + p2;
156 
157         // Equinoctial reference frame [Eq. 2.1.4-(1)]
158         final double ooC = 1. / C;
159         final double px2 = 2. * p;
160         final double qx2 = 2. * q;
161         final double pq2 = px2 * q;
162         f = new Vector3D(ooC, new Vector3D(1. - p2 + q2, pq2, -px2 * I));
163         g = new Vector3D(ooC, new Vector3D(pq2 * I, (1. + p2 - q2) * I, qx2));
164         w = new Vector3D(ooC, new Vector3D(px2, -qx2, (1. - p2 - q2) * I));
165 
166         // Direction cosines for central body [Eq. 2.1.9-(1)]
167         alpha = f.getZ();
168         beta  = g.getZ();
169         gamma = w.getZ();
170     }
171 
172     /** Get the date of the orbit.
173      * @return the date
174      */
175     public AbsoluteDate getDate() {
176         return date;
177     }
178 
179     /** Get the definition frame of the orbit.
180      * @return the definition frame
181      */
182     public Frame getFrame() {
183         return frame;
184     }
185 
186     /** Get the central body attraction coefficient.
187      * @return &mu;
188      */
189     public double getMu() {
190         return mu;
191     }
192 
193     /** Get the eccentricity.
194      * @return ecc
195      */
196     public double getEcc() {
197         return ecc;
198     }
199 
200     /** Get the Keplerian mean motion.
201      * @return n
202      */
203     public double getMeanMotion() {
204         return n;
205     }
206 
207     /** Get the Keplerian period.
208      * @return period
209      */
210     public double getKeplerianPeriod() {
211         return period;
212     }
213 
214     /** Get the semi-major axis.
215      * @return the semi-major axis a
216      */
217     public double getSma() {
218         return sma;
219     }
220 
221     /** Get the x component of eccentricity vector.
222      * <p>
223      * This element called k in DSST corresponds to ex
224      * for the {@link org.orekit.orbits.EquinoctialOrbit}
225      * </p>
226      * @return k
227      */
228     public double getK() {
229         return k;
230     }
231 
232     /** Get the y component of eccentricity vector.
233      * <p>
234      * This element called h in DSST corresponds to ey
235      * for the {@link org.orekit.orbits.EquinoctialOrbit}
236      * </p>
237      * @return h
238      */
239     public double getH() {
240         return h;
241     }
242 
243     /** Get the x component of inclination vector.
244      * <p>
245      * This element called q in DSST corresponds to hx
246      * for the {@link org.orekit.orbits.EquinoctialOrbit}
247      * </p>
248      * @return q
249      */
250     public double getQ() {
251         return q;
252     }
253 
254     /** Get the y component of inclination vector.
255      * <p>
256      * This element called p in DSST corresponds to hy
257      * for the {@link org.orekit.orbits.EquinoctialOrbit}
258      * </p>
259      * @return p
260      */
261     public double getP() {
262         return p;
263     }
264 
265     /** Get the mean longitude.
266      * @return lm
267      */
268     public double getLM() {
269         return lm;
270     }
271 
272     /** Get the retrograde factor.
273      * @return the retrograde factor I
274      */
275     public int getRetrogradeFactor() {
276         return I;
277     }
278 
279     /** Get A = sqrt(&mu; * a).
280      * @return A
281      */
282     public double getA() {
283         return A;
284     }
285 
286     /** Get B = sqrt(1 - e<sup>2</sup>).
287      * @return B
288      */
289     public double getB() {
290         return B;
291     }
292 
293     /** Get C = 1 + p<sup>2</sup> + q<sup>2</sup>.
294      * @return C
295      */
296     public double getC() {
297         return C;
298     }
299 
300     /** Get equinoctial frame vector f.
301      * @return f vector
302      */
303     public Vector3D getVectorF() {
304         return f;
305     }
306 
307     /** Get equinoctial frame vector g.
308      * @return g vector
309      */
310     public Vector3D getVectorG() {
311         return g;
312     }
313 
314     /** Get equinoctial frame vector w.
315      * @return w vector
316      */
317     public Vector3D getVectorW() {
318         return w;
319     }
320 
321     /** Get direction cosine &alpha; for central body.
322      * @return &alpha;
323      */
324     public double getAlpha() {
325         return alpha;
326     }
327 
328     /** Get direction cosine &beta; for central body.
329      * @return &beta;
330      */
331     public double getBeta() {
332         return beta;
333     }
334 
335     /** Get direction cosine &gamma; for central body.
336      * @return &gamma;
337      */
338     public double getGamma() {
339         return gamma;
340     }
341 
342 }