1   /* Copyright 2022-2025 Bryan Cazabonne
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    * Bryan Cazabonne 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.forces;
18  
19  import org.hipparchus.util.FastMath;
20  import org.hipparchus.util.SinCos;
21  import org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
22  import org.orekit.propagation.semianalytical.dsst.utilities.AuxiliaryElements;
23  
24  /**
25   * This class is a container for the common parameters used in {@link DSSTJ2SquaredClosedForm}.
26   * <p>
27   * It performs parameters initialization at each integration step for the second-order J2-squared
28   * contribution to the central body gravitational perturbation.
29   * </p>
30   * @author Bryan Cazabonne
31   * @since 12.0
32   */
33  public class DSSTJ2SquaredClosedFormContext extends ForceModelContext {
34  
35      /** Equatorial radius of the central body to the power 4. */
36      private final double alpha4;
37  
38      /** Semi major axis to the power 4. */
39      private final double a4;
40  
41      /** sqrt(1 - e * e). */
42      private final double eta;
43  
44      /** Cosine of the inclination. */
45      private final double c;
46  
47      /** Sine of the inclination to the power 2. */
48      private final double s2;
49  
50      /**
51       * Simple constructor.
52       *
53       * @param auxiliaryElements auxiliary elements related to the current orbit
54       * @param provider          provider for spherical harmonics
55       */
56      public DSSTJ2SquaredClosedFormContext(final AuxiliaryElements auxiliaryElements,
57                                            final UnnormalizedSphericalHarmonicsProvider provider) {
58          super(auxiliaryElements);
59  
60          // Sine and cosine of the inclination
61          final double inc = auxiliaryElements.getOrbit().getI();
62          final SinCos scI = FastMath.sinCos(inc);
63  
64          // Other parameters
65          this.c = scI.cos();
66          this.s2 = scI.sin() * scI.sin();
67  
68          final double alpha2 = provider.getAe() * provider.getAe();
69          this.alpha4 = alpha2 * alpha2;
70  
71          this.eta = FastMath.sqrt(1.0 - auxiliaryElements.getEcc() * auxiliaryElements.getEcc());
72  
73          final double a2 = auxiliaryElements.getSma() * auxiliaryElements.getSma();
74          this.a4 = a2 * a2;
75      }
76  
77      /**
78       * Get the equatorial radius of the central body to the power 4.
79       * @return the equatorial radius of the central body to the power 4
80       */
81      public double getAlpha4() {
82          return alpha4;
83      }
84  
85      /**
86       * Get the semi major axis to the power 4.
87       * @return the semi major axis to the power 4
88       */
89      public double getA4() {
90          return a4;
91      }
92  
93      /**
94       * Get the eta value.
95       * @return sqrt(1 - e * e)
96       */
97      public double getEta() {
98          return eta;
99      }
100 
101     /**
102      * Get the cosine of the inclination.
103      * @return the cosine of the inclination
104      */
105     public double getC() {
106         return c;
107     }
108 
109     /**
110      * Get the sine of the inclination to the power 2.
111      * @return the sine of the inclination to the power 2
112      */
113     public double getS2() {
114         return s2;
115     }
116 
117 }