OneDVariation.java

  1. /* Copyright 2002-2025 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.gnss.antenna;

  18. import org.hipparchus.util.FastMath;

  19. /**
  20.  * Interpolator for 1D phase center variation data.
  21.  *
  22.  * @author Luc Maisonobe
  23.  * @since 9.2
  24.  */
  25. public class OneDVariation implements PhaseCenterVariationFunction {

  26.     /** Start polar angle. */
  27.     private final double polarStart;

  28.     /** Step between grid points. */
  29.     private final double polarStep;

  30.     /** Sampled phase center variations. */
  31.     private final double[] variations;

  32.     /** Simple constructor.
  33.      * @param polarStart start polar angle
  34.      * @param polarStep between grid points
  35.      * @param variations sampled phase center variations
  36.      */
  37.     public OneDVariation(final double polarStart, final double polarStep, final double[] variations) {
  38.         this.polarStart = polarStart;
  39.         this.polarStep  = polarStep;
  40.         this.variations = variations.clone();
  41.     }

  42.     /** {@inheritDoc} */
  43.     @Override
  44.     public double value(final double polarAngle, final double azimuthAngle) {

  45.         // find surrounding points
  46.         final int    jBase = (int) FastMath.floor((polarAngle - polarStart) / polarStep);
  47.         final int    j     = FastMath.max(0, FastMath.min(variations.length - 2, jBase));

  48.         final double pInf  = polarStart + j * polarStep;
  49.         final double pSup  = pInf + polarStep;

  50.         final double vInf  = variations[j];
  51.         final double vSup  = variations[j + 1];

  52.         // linear interpolation
  53.         return ((polarAngle - pInf) * vSup + (pSup - polarAngle) * vInf) / polarStep;

  54.     }

  55. }