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.forces.gravity.potential;
18
19 import org.hipparchus.util.SinCos;
20
21 /** Part of a {@link PiecewiseSphericalHarmonics piecewise gravity fields} valid for one time interval.
22 * @author Luc Maisonobe
23 * @since 11.1
24 */
25 class PiecewisePart {
26
27 /** Converter between (degree, order) indices and flatten array. */
28 private final Flattener flattener;
29
30 /** Components of the spherical harmonics. */
31 private final TimeDependentHarmonic[] components;
32
33 /** Simple constructor.
34 * @param flattener converter between (degree, order) indices and flatten array
35 * @param components components of the spherical harmonics
36 */
37 PiecewisePart(final Flattener flattener, final TimeDependentHarmonic[] components) {
38 this.flattener = flattener;
39 this.components = components.clone();
40 }
41
42 /** Get the maximum supported degree.
43 * @return maximal supported degree
44 */
45 public int getMaxDegree() {
46 return flattener.getDegree();
47 }
48
49 /** Get the maximal supported order.
50 * @return maximal supported order
51 */
52 public int getMaxOrder() {
53 return flattener.getOrder();
54 }
55
56 /** Compute the time-dependent part of a spherical harmonic cosine coefficient.
57 * @param n degree of the coefficient
58 * @param m order of the coefficient
59 * @param offsets offsets to reference dates in the gravity field
60 * @param pulsations angular pulsations in the gravity field
61 * @return raw coefficient Cnm
62 */
63 public double computeCnm(final int n, final int m,
64 final double[] offsets, final SinCos[][] pulsations) {
65 final TimeDependentHarmonic harmonic = components[flattener.index(n, m)];
66 return harmonic == null ? 0.0 : harmonic.computeCnm(offsets, pulsations);
67 }
68
69 /** Compute the time-dependent part of a spherical harmonic sine coefficient.
70 * @param n degree of the coefficient
71 * @param m order of the coefficient
72 * @param offsets offsets to reference dates in the gravity field
73 * @param pulsations angular pulsations in the gravity field
74 * @return raw coefficient Snm
75 */
76 public double computeSnm(final int n, final int m,
77 final double[] offsets, final SinCos[][] pulsations) {
78 final TimeDependentHarmonic harmonic = components[flattener.index(n, m)];
79 return harmonic == null ? 0.0 : harmonic.computeSnm(offsets, pulsations);
80 }
81
82 }