Normalizer.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.UnnormalizedSphericalHarmonicsProvider.UnnormalizedSphericalHarmonics;
  20. import org.orekit.time.AbsoluteDate;

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

  26.     /** Un-normalized provider to which everything is delegated. */
  27.     private final UnnormalizedSphericalHarmonicsProvider unnormalized;

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

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

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

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

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

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

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

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

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

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

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

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

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

  98.         };
  99.     }

  100. }