Unnormalizer.java

  1. /* Copyright 2002-2024 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. import org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider.NormalizedSphericalHarmonics;
  19. import org.orekit.time.AbsoluteDate;

  20. /** Wrapper providing un-normalized coefficients from normalized ones.
  21.  * @author Luc Maisonobe
  22.  * @since 6.0
  23.  */
  24. class Unnormalizer implements UnnormalizedSphericalHarmonicsProvider {

  25.     /** Normalized provider to which everything is delegated. */
  26.     private final NormalizedSphericalHarmonicsProvider normalized;

  27.     /** Factors for un-normalization. */
  28.     private final double[][] factors;

  29.     /** Simple constructor.
  30.      * @param normalized provider to un-normalize
  31.      */
  32.     Unnormalizer(final NormalizedSphericalHarmonicsProvider normalized) {
  33.         this.normalized = normalized;
  34.         this.factors    = GravityFieldFactory.getUnnormalizationFactors(normalized.getMaxDegree(),
  35.                                                                         normalized.getMaxOrder());
  36.     }

  37.     /** {@inheritDoc} */
  38.     @Override
  39.     public int getMaxDegree() {
  40.         return normalized.getMaxDegree();
  41.     }

  42.     /** {@inheritDoc} */
  43.     @Override
  44.     public int getMaxOrder() {
  45.         return normalized.getMaxOrder();
  46.     }

  47.     /** {@inheritDoc} */
  48.     @Override
  49.     public double getMu() {
  50.         return normalized.getMu();
  51.     }

  52.     /** {@inheritDoc} */
  53.     @Override
  54.     public double getAe() {
  55.         return normalized.getAe();
  56.     }

  57.     /** {@inheritDoc} */
  58.     @Override
  59.     public AbsoluteDate getReferenceDate() {
  60.         return normalized.getReferenceDate();
  61.     }

  62.     /** {@inheritDoc} */
  63.     @Override
  64.     public TideSystem getTideSystem() {
  65.         return normalized.getTideSystem();
  66.     }

  67.     /** {@inheritDoc} */
  68.     @Override
  69.     public UnnormalizedSphericalHarmonics onDate(final AbsoluteDate date) {
  70.         final NormalizedSphericalHarmonics harmonics = normalized.onDate(date);
  71.         return new UnnormalizedSphericalHarmonics() {

  72.             /** {@inheritDoc} */
  73.             @Override
  74.             public AbsoluteDate getDate() {
  75.                 return date;
  76.             }

  77.             /** {@inheritDoc} */
  78.             @Override
  79.             public double getUnnormalizedCnm(final int n, final int m) {
  80.                 return harmonics.getNormalizedCnm(n, m) * factors[n][m];
  81.             }

  82.             /** {@inheritDoc} */
  83.             @Override
  84.             public double getUnnormalizedSnm(final int n, final int m) {
  85.                 return harmonics.getNormalizedSnm(n, m) * factors[n][m];
  86.             }

  87.         };
  88.     }

  89. }