PiecewisePart.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.hipparchus.util.SinCos;

  19. /** Part of a {@link PiecewiseSphericalHarmonics piecewise gravity fields} valid for one time interval.
  20.  * @author Luc Maisonobe
  21.  * @since 11.1
  22.  */
  23. class PiecewisePart {

  24.     /** Converter between (degree, order) indices and flatten array. */
  25.     private final Flattener flattener;

  26.     /** Components of the spherical harmonics. */
  27.     private final TimeDependentHarmonic[] components;

  28.     /** Simple constructor.
  29.      * @param flattener converter between (degree, order) indices and flatten array
  30.      * @param components components of the spherical harmonics
  31.      */
  32.     PiecewisePart(final Flattener flattener, final TimeDependentHarmonic[] components) {
  33.         this.flattener  = flattener;
  34.         this.components = components.clone();
  35.     }

  36.     /** Get the maximum supported degree.
  37.      * @return maximal supported degree
  38.      */
  39.     public int getMaxDegree() {
  40.         return flattener.getDegree();
  41.     }

  42.     /** Get the maximal supported order.
  43.      * @return maximal supported order
  44.      */
  45.     public int getMaxOrder() {
  46.         return flattener.getOrder();
  47.     }

  48.     /** Compute the time-dependent part of a spherical harmonic cosine coefficient.
  49.      * @param n degree of the coefficient
  50.      * @param m order of the coefficient
  51.      * @param offsets offsets to reference dates in the gravity field
  52.      * @param pulsations angular pulsations in the gravity field
  53.      * @return raw coefficient Cnm
  54.      */
  55.     public double computeCnm(final int n, final int m,
  56.                              final double[] offsets, final SinCos[][] pulsations) {
  57.         final TimeDependentHarmonic harmonic = components[flattener.index(n, m)];
  58.         return harmonic == null ? 0.0 : harmonic.computeCnm(offsets, pulsations);
  59.     }

  60.     /** Compute the time-dependent part of a spherical harmonic sine coefficient.
  61.      * @param n degree of the coefficient
  62.      * @param m order of the coefficient
  63.      * @param offsets offsets to reference dates in the gravity field
  64.      * @param pulsations angular pulsations in the gravity field
  65.      * @return raw coefficient Snm
  66.      */
  67.     public double computeSnm(final int n, final int m,
  68.                              final double[] offsets, final SinCos[][] pulsations) {
  69.         final TimeDependentHarmonic harmonic = components[flattener.index(n, m)];
  70.         return harmonic == null ? 0.0 : harmonic.computeSnm(offsets, pulsations);
  71.     }

  72. }