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