Unnormalizer.java

  1. /* Copyright 2002-2015 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.errors.OrekitException;
  19. import org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider.NormalizedSphericalHarmonics;
  20. import org.orekit.time.AbsoluteDate;

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

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

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

  30.     /** Simple constructor.
  31.      * @param normalized provider to un-normalize
  32.      * @exception OrekitException if degree and order are too large
  33.      * and the un-normalization coefficients underflow
  34.      */
  35.     public Unnormalizer(final NormalizedSphericalHarmonicsProvider normalized)
  36.         throws OrekitException {
  37.         this.normalized = normalized;
  38.         this.factors    = GravityFieldFactory.getUnnormalizationFactors(normalized.getMaxDegree(),
  39.                                                                         normalized.getMaxOrder());
  40.     }

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

  46.     /** {@inheritDoc} */
  47.     @Override
  48.     public int getMaxOrder() {
  49.         return normalized.getMaxOrder();
  50.     }

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

  56.     /** {@inheritDoc} */
  57.     @Override
  58.     public double getAe() {
  59.         return normalized.getAe();
  60.     }

  61.     /** {@inheritDoc} */
  62.     @Override
  63.     public AbsoluteDate getReferenceDate() {
  64.         return normalized.getReferenceDate();
  65.     }

  66.     /** {@inheritDoc} */
  67.     @Override
  68.     public double getOffset(final AbsoluteDate date) {
  69.         return normalized.getOffset(date);
  70.     }

  71.     /** {@inheritDoc} */
  72.     @Override
  73.     public TideSystem getTideSystem() {
  74.         return normalized.getTideSystem();
  75.     }

  76.     /** {@inheritDoc} */
  77.     @Override
  78.     public UnnormalizedSphericalHarmonics onDate(final AbsoluteDate date) throws OrekitException {
  79.         final NormalizedSphericalHarmonics harmonics = normalized.onDate(date);
  80.         return new UnnormalizedSphericalHarmonics() {

  81.             /** {@inheritDoc} */
  82.             @Override
  83.             public AbsoluteDate getDate() {
  84.                 return date;
  85.             }

  86.             /** {@inheritDoc} */
  87.             @Override
  88.             public double getUnnormalizedCnm(final int n, final int m) throws OrekitException {
  89.                 return harmonics.getNormalizedCnm(n, m) * factors[n][m];
  90.             }

  91.             /** {@inheritDoc} */
  92.             @Override
  93.             public double getUnnormalizedSnm(final int n, final int m) throws OrekitException {
  94.                 return harmonics.getNormalizedSnm(n, m) * factors[n][m];
  95.             }

  96.         };
  97.     }

  98. }