Unnormalizer.java

  1. /* Copyright 2002-2022 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.     @Deprecated
  64.     @Override
  65.     public double getOffset(final AbsoluteDate date) {
  66.         return normalized.getOffset(date);
  67.     }

  68.     /** {@inheritDoc} */
  69.     @Override
  70.     public TideSystem getTideSystem() {
  71.         return normalized.getTideSystem();
  72.     }

  73.     /** {@inheritDoc} */
  74.     @Override
  75.     public UnnormalizedSphericalHarmonics onDate(final AbsoluteDate date) {
  76.         final NormalizedSphericalHarmonics harmonics = normalized.onDate(date);
  77.         return new UnnormalizedSphericalHarmonics() {

  78.             /** {@inheritDoc} */
  79.             @Override
  80.             public AbsoluteDate getDate() {
  81.                 return date;
  82.             }

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

  88.             /** {@inheritDoc} */
  89.             @Override
  90.             public double getUnnormalizedSnm(final int n, final int m) {
  91.                 return harmonics.getNormalizedSnm(n, m) * factors[n][m];
  92.             }

  93.         };
  94.     }

  95. }