ElevationDetectionAdaptableIntervalFactory.java

  1. /* Copyright 2002-2024 Luc Maisonobe
  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.propagation.events.intervals;

  18. import org.hipparchus.util.FastMath;
  19. import org.orekit.frames.TopocentricFrame;
  20. import org.orekit.frames.Transform;
  21. import org.orekit.orbits.Orbit;
  22. import org.orekit.propagation.events.AdaptableInterval;

  23. /**
  24.  * Factory class for {@link AdaptableInterval} suitable for elevation detection on eccentric orbits.
  25.  * It requires {@link org.orekit.propagation.SpacecraftState} to be based on {@link Orbit} in order to work.
  26.  * @see AdaptableInterval
  27.  * @see org.orekit.propagation.events.ApsideDetector
  28.  * @see org.orekit.propagation.events.EventSlopeFilter
  29.  * @author Luc Maisonobe
  30.  * @since 12.1
  31.  */
  32. public class ElevationDetectionAdaptableIntervalFactory {

  33.     /** Default elevation abovde which interval should be switched to fine interval (-5°). */
  34.     public static final double DEFAULT_ELEVATION_SWITCH = FastMath.toRadians(-5.0);

  35.     /**
  36.      * Private constructor.
  37.      */
  38.     private ElevationDetectionAdaptableIntervalFactory() {
  39.         // factory class
  40.     }

  41.     /**
  42.      * Method providing a candidate {@link AdaptableInterval} for arbitrary elevation detection with forward propagation.
  43.      * It uses a Keplerian, eccentric approximation.
  44.      * @param topo topocentric frame centered at ground interest point
  45.      * @param elevationSwitch elevation above which interval will switch to {@code fineCheckInterval}
  46.      *                        (typically {@link #DEFAULT_ELEVATION_SWITCH} which is -5°)
  47.      * @param fineCheckInterval check interval to use when elevation is above {@code elevationSwitch}
  48.      * @return adaptable interval for detection of elevation with respect to {@code topo}
  49.      */
  50.     public static AdaptableInterval getAdaptableInterval(final TopocentricFrame topo,
  51.                                                          final double elevationSwitch,
  52.                                                          final double fineCheckInterval) {
  53.         return state -> {
  54.             final double elevation = topo.getElevation(state.getPosition(), state.getFrame(), state.getDate());
  55.             if (elevation <= elevationSwitch) {
  56.                 // we are far from visibility, estimate some large interval with huge margins

  57.                 // rotation rate of the topocentric frame
  58.                 final Transform topoToInertial = topo.getTransformTo(state.getFrame(), state.getDate());
  59.                 final double topoAngularVelocity = topoToInertial.getAngular().getRotationRate().getNorm();

  60.                 // max angular rate of spacecraft (i.e. rate at perigee)
  61.                 final double e     = state.getE();
  62.                 final double rp    = state.getA() * (1 - e);
  63.                 final double vp    = FastMath.sqrt(state.getMu() * (1 + e) / rp);
  64.                 final double rateP = vp / rp;

  65.                 // upper boundary of elevation rate
  66.                 final double maxElevationRate = topoAngularVelocity + rateP;

  67.                 return FastMath.max(fineCheckInterval, (elevationSwitch - elevation) / maxElevationRate);

  68.             } else {
  69.                 // we are close to visibility, switch to fine check interval
  70.                 return fineCheckInterval;
  71.             }
  72.         };
  73.     }

  74. }