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.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider.NormalizedSphericalHarmonics;
20  import org.orekit.time.AbsoluteDate;
21  
22  /** Wrapper providing un-normalized coefficients from normalized ones.
23   * @author Luc Maisonobe
24   * @since 6.0
25   */
26  class Unnormalizer implements UnnormalizedSphericalHarmonicsProvider {
27  
28      /** Normalized provider to which everything is delegated. */
29      private final NormalizedSphericalHarmonicsProvider normalized;
30  
31      /** Factors for un-normalization. */
32      private final double[][] factors;
33  
34      /** Simple constructor.
35       * @param normalized provider to un-normalize
36       */
37      Unnormalizer(final NormalizedSphericalHarmonicsProvider normalized) {
38          this.normalized = normalized;
39          this.factors    = GravityFieldFactory.getUnnormalizationFactors(normalized.getMaxDegree(),
40                                                                          normalized.getMaxOrder());
41      }
42  
43      /** {@inheritDoc} */
44      @Override
45      public int getMaxDegree() {
46          return normalized.getMaxDegree();
47      }
48  
49      /** {@inheritDoc} */
50      @Override
51      public int getMaxOrder() {
52          return normalized.getMaxOrder();
53      }
54  
55      /** {@inheritDoc} */
56      @Override
57      public double getMu() {
58          return normalized.getMu();
59      }
60  
61      /** {@inheritDoc} */
62      @Override
63      public double getAe() {
64          return normalized.getAe();
65      }
66  
67      /** {@inheritDoc} */
68      @Override
69      public AbsoluteDate getReferenceDate() {
70          return normalized.getReferenceDate();
71      }
72  
73      /** {@inheritDoc} */
74      @Override
75      public TideSystem getTideSystem() {
76          return normalized.getTideSystem();
77      }
78  
79      /** {@inheritDoc} */
80      @Override
81      public UnnormalizedSphericalHarmonics onDate(final AbsoluteDate date) {
82          final NormalizedSphericalHarmonics harmonics = normalized.onDate(date);
83          return new UnnormalizedSphericalHarmonics() {
84  
85              /** {@inheritDoc} */
86              @Override
87              public AbsoluteDate getDate() {
88                  return date;
89              }
90  
91              /** {@inheritDoc} */
92              @Override
93              public double getUnnormalizedCnm(final int n, final int m) {
94                  return harmonics.getNormalizedCnm(n, m) * factors[n][m];
95              }
96  
97              /** {@inheritDoc} */
98              @Override
99              public double getUnnormalizedSnm(final int n, final int m) {
100                 return harmonics.getNormalizedSnm(n, m) * factors[n][m];
101             }
102 
103         };
104     }
105 
106 }