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  package org.orekit.propagation.semianalytical.dsst.utilities;
18  
19  
20  /** Compute the G<sub>js</sub>, H<sub>js</sub>, I<sub>js</sub> and J<sub>js</sub>
21   *  polynomials in the equinoctial elements h, k and the direction cosines α and β
22   *  and their partial derivatives with respect to k, h, α and β.
23   *  <p>
24   *  The expressions used are equations 4.1-(10) from the Danielson paper.
25   *  </p>
26   *  @author Lucian Barbulescu
27   */
28  public class GHIJjsPolynomials {
29  
30      /** C<sub>j</sub>(k, h), S<sub>j</sub>(k, h) coefficient.
31       * (k, h) are the (x, y) component of the eccentricity vector in equinoctial elements
32       */
33      private final CjSjCoefficient cjsjKH;
34  
35      /** C<sub>j</sub>(α, β), S<sub>j</sub>(α, β) coefficient.
36       * (α, β) are the direction cosines
37       */
38      private final CjSjCoefficient cjsjAB;
39  
40      /** Create a set of G<sub>js</sub>, H<sub>js</sub>, I<sub>js</sub> and J<sub>js</sub> polynomials.
41       *  @param k X component of the eccentricity vector
42       *  @param h Y component of the eccentricity vector
43       *  @param alpha direction cosine α
44       *  @param beta direction cosine β
45       **/
46      public GHIJjsPolynomials(final double k, final double h,
47                              final double alpha, final double beta) {
48          this.cjsjKH = new CjSjCoefficient(k, h);
49          this.cjsjAB = new CjSjCoefficient(alpha, beta);
50      }
51  
52      /** Get the G<sub>js</sub> coefficient.
53       * @param j j subscript
54       * @param s s subscript
55       * @return the G<sub>js</sub>
56       */
57      public double getGjs(final int j, final int s) {
58          return cjsjKH.getCj(j) * cjsjAB.getCj(s) + cjsjKH.getSj(j) * cjsjAB.getSj(s);
59      }
60  
61      /** Get the dG<sub>js</sub> / dk coefficient.
62       * @param j j subscript
63       * @param s s subscript
64       * @return the dG<sub>js</sub> / dk
65       */
66      public double getdGjsdk(final int j, final int s) {
67          return cjsjKH.getDcjDk(j) * cjsjAB.getCj(s) + cjsjKH.getDsjDk(j) * cjsjAB.getSj(s);
68      }
69  
70      /** Get the dG<sub>js</sub> / dh coefficient.
71       * @param j j subscript
72       * @param s s subscript
73       * @return the dG<sub>js</sub> / dh
74       */
75      public double getdGjsdh(final int j, final int s) {
76          return cjsjKH.getDcjDh(j) * cjsjAB.getCj(s) + cjsjKH.getDsjDh(j) * cjsjAB.getSj(s);
77      }
78  
79      /** Get the dG<sub>js</sub> / dα coefficient.
80       * @param j j subscript
81       * @param s s subscript
82       * @return the dG<sub>js</sub> / dα
83       */
84      public double getdGjsdAlpha(final int j, final int s) {
85          return cjsjKH.getCj(j) * cjsjAB.getDcjDk(s) + cjsjKH.getSj(j) * cjsjAB.getDsjDk(s);
86      }
87  
88      /** Get the dG<sub>js</sub> / dβ coefficient.
89       * @param j j subscript
90       * @param s s subscript
91       * @return the dG<sub>js</sub> / dβ
92       */
93      public double getdGjsdBeta(final int j, final int s) {
94          return cjsjKH.getCj(j) * cjsjAB.getDcjDh(s) + cjsjKH.getSj(j) * cjsjAB.getDsjDh(s);
95      }
96  
97      /** Get the H<sub>js</sub> coefficient.
98       * @param j j subscript
99       * @param s s subscript
100      * @return the H<sub>js</sub>
101      */
102     public double getHjs(final int j, final int s) {
103         return cjsjKH.getCj(j) * cjsjAB.getSj(s) - cjsjKH.getSj(j) * cjsjAB.getCj(s);
104     }
105 
106     /** Get the dH<sub>js</sub> / dk coefficient.
107      * @param j j subscript
108      * @param s s subscript
109      * @return the H<sub>js</sub> / dk
110      */
111     public double getdHjsdk(final int j, final int s) {
112         return cjsjKH.getDcjDk(j) * cjsjAB.getSj(s) - cjsjKH.getDsjDk(j) * cjsjAB.getCj(s);
113     }
114 
115     /** Get the dH<sub>js</sub> / dh coefficient.
116      * @param j j subscript
117      * @param s s subscript
118      * @return the H<sub>js</sub> / dh
119      */
120     public double getdHjsdh(final int j, final int s) {
121         return cjsjKH.getDcjDh(j) * cjsjAB.getSj(s) - cjsjKH.getDsjDh(j) * cjsjAB.getCj(s);
122     }
123 
124     /** Get the dH<sub>js</sub> / dα coefficient.
125      * @param j j subscript
126      * @param s s subscript
127      * @return the H<sub>js</sub> / dα
128      */
129     public double getdHjsdAlpha(final int j, final int s) {
130         return cjsjKH.getCj(j) * cjsjAB.getDsjDk(s) - cjsjKH.getSj(j) * cjsjAB.getDcjDk(s);
131     }
132 
133     /** Get the dH<sub>js</sub> / dβ coefficient.
134      * @param j j subscript
135      * @param s s subscript
136      * @return the H<sub>js</sub> / dβ
137      */
138     public double getdHjsdBeta(final int j, final int s) {
139         return cjsjKH.getCj(j) * cjsjAB.getDsjDh(s) - cjsjKH.getSj(j) * cjsjAB.getDcjDh(s);
140     }
141 
142     /** Get the I<sub>js</sub> coefficient.
143      * @param j j subscript
144      * @param s s subscript
145      * @return the I<sub>js</sub>
146      */
147     public double getIjs(final int j, final int s) {
148         return cjsjKH.getCj(j) * cjsjAB.getSj(s) + cjsjKH.getSj(j) * cjsjAB.getCj(s);
149     }
150 
151     /** Get the dI<sub>js</sub> / dk coefficient.
152      * @param j j subscript
153      * @param s s subscript
154      * @return the I<sub>js</sub> / dk
155      */
156     public double getdIjsdk(final int j, final int s) {
157         return cjsjKH.getDcjDk(j) * cjsjAB.getSj(s) + cjsjKH.getDsjDk(j) * cjsjAB.getCj(s);
158     }
159 
160     /** Get the dI<sub>js</sub> / dh coefficient.
161      * @param j j subscript
162      * @param s s subscript
163      * @return the I<sub>js</sub> / dh
164      */
165     public double getdIjsdh(final int j, final int s) {
166         return cjsjKH.getDcjDh(j) * cjsjAB.getSj(s) + cjsjKH.getDsjDh(j) * cjsjAB.getCj(s);
167     }
168 
169     /** Get the dI<sub>js</sub> / dα coefficient.
170      * @param j j subscript
171      * @param s s subscript
172      * @return the I<sub>js</sub> / dα
173      */
174     public double getdIjsdAlpha(final int j, final int s) {
175         return cjsjKH.getCj(j) * cjsjAB.getDsjDk(s) + cjsjKH.getSj(j) * cjsjAB.getDcjDk(s);
176     }
177 
178     /** Get the dI<sub>js</sub> / dβ coefficient.
179      * @param j j subscript
180      * @param s s subscript
181      * @return the I<sub>js</sub> / dβ
182      */
183     public double getdIjsdBeta(final int j, final int s) {
184         return cjsjKH.getCj(j) * cjsjAB.getDsjDh(s) + cjsjKH.getSj(j) * cjsjAB.getDcjDh(s);
185     }
186 
187     /** Get the J<sub>js</sub> coefficient.
188      * @param j j subscript
189      * @param s s subscript
190      * @return the J<sub>js</sub>
191      */
192     public double getJjs(final int j, final int s) {
193         return cjsjKH.getCj(j) * cjsjAB.getCj(s) - cjsjKH.getSj(j) * cjsjAB.getSj(s);
194     }
195 
196     /** Get the dJ<sub>js</sub> / dk coefficient.
197      * @param j j subscript
198      * @param s s subscript
199      * @return the J<sub>js</sub> / dk
200      */
201     public double getdJjsdk(final int j, final int s) {
202         return cjsjKH.getDcjDk(j) * cjsjAB.getCj(s) - cjsjKH.getDsjDk(j) * cjsjAB.getSj(s);
203     }
204     /** Get the dJ<sub>js</sub> / dh coefficient.
205      * @param j j subscript
206      * @param s s subscript
207      * @return the J<sub>js</sub> / dh
208      */
209     public double getdJjsdh(final int j, final int s) {
210         return cjsjKH.getDcjDh(j) * cjsjAB.getCj(s) - cjsjKH.getDsjDh(j) * cjsjAB.getSj(s);
211     }
212     /** Get the dJ<sub>js</sub> / dα coefficient.
213      * @param j j subscript
214      * @param s s subscript
215      * @return the J<sub>js</sub> / dα
216      */
217     public double getdJjsdAlpha(final int j, final int s) {
218         return cjsjKH.getCj(j) * cjsjAB.getDcjDk(s) - cjsjKH.getSj(j) * cjsjAB.getDsjDk(s);
219     }
220     /** Get the dJ<sub>js</sub> / dβ coefficient.
221      * @param j j subscript
222      * @param s s subscript
223      * @return the J<sub>js</sub> / dβ
224      */
225     public double getdJjsdBeta(final int j, final int s) {
226         return cjsjKH.getCj(j) * cjsjAB.getDcjDh(s) - cjsjKH.getSj(j) * cjsjAB.getDsjDh(s);
227     }
228 }