InterSatDirectViewDetector.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.propagation.events;

  18. import org.orekit.bodies.GeodeticPoint;
  19. import org.orekit.bodies.OneAxisEllipsoid;
  20. import org.orekit.frames.Frame;
  21. import org.orekit.propagation.PropagatorsParallelizer;
  22. import org.orekit.propagation.SpacecraftState;
  23. import org.orekit.propagation.events.handlers.ContinueOnEvent;
  24. import org.orekit.propagation.events.handlers.EventHandler;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.utils.PVCoordinatesProvider;


  27. /** Detector for inter-satellites direct view (i.e. no masking by central body limb).
  28.  * <p>
  29.  * As this detector needs two satellites, it embeds one {@link
  30.  * PVCoordinatesProvider coordinates provider} for the secondary satellite
  31.  * and is registered as an event detector in the propagator of the primary
  32.  * satellite. The secondary satellite provider will therefore be driven by this
  33.  * detector (and hence by the propagator in which this detector is registered).
  34.  * </p>
  35.  * <p>
  36.  * In order to avoid infinite recursion, care must be taken to have the secondary
  37.  * satellite provider being <em>completely independent</em> from anything else.
  38.  * In particular, if the provider is a propagator, it should <em>not</em> be run
  39.  * together in a {@link PropagatorsParallelizer propagators parallelizer} with
  40.  * the propagator this detector is registered in. It is fine however to configure
  41.  * two separate propagators PsA and PsB with similar settings for the secondary satellite
  42.  * and one propagator Pm for the primary satellite and then use Psa in this detector
  43.  * registered within Pm while Pm and Psb are run in the context of a {@link
  44.  * PropagatorsParallelizer propagators parallelizer}.
  45.  * </p>
  46.  * <p>
  47.  * For efficiency reason during the event search loop, it is recommended to have
  48.  * the secondary provider be an analytical propagator or an ephemeris. A numerical propagator
  49.  * as a secondary propagator works but is expected to be computationally costly.
  50.  * </p>
  51.  * <p>
  52.  * The {@code g} function of this detector is positive when satellites can see
  53.  * each other directly and negative when the central body limb is in between and
  54.  * blocks the direct view.
  55.  * </p>
  56.  * <p>
  57.  * This detector only checks masking by central body limb, it does not take into
  58.  * account satellites antenna patterns. If these patterns must be considered, then
  59.  * this detector can be {@link BooleanDetector#andCombine(EventDetector...) and combined}
  60.  * with  the {@link BooleanDetector#notCombine(EventDetector) logical not} of
  61.  * {@link FieldOfViewDetector field of view detectors}.
  62.  * </p>
  63.  * @author Luc Maisonobe
  64.  * @since 9.3
  65.  */
  66. public class InterSatDirectViewDetector extends AbstractDetector<InterSatDirectViewDetector> {

  67.     /** Central body. */
  68.     private final OneAxisEllipsoid body;

  69.     /** Skimming altitude.
  70.      * @since 12.0
  71.      */
  72.     private final double skimmingAltitude;

  73.     /** Coordinates provider for the secondary satellite. */
  74.     private final PVCoordinatesProvider secondary;

  75.     /** simple constructor.
  76.      *
  77.      * @param body central body
  78.      * @param secondary provider for the secondary satellite
  79.      */
  80.     public InterSatDirectViewDetector(final OneAxisEllipsoid body, final PVCoordinatesProvider secondary) {
  81.         this(body, 0.0, secondary, EventDetectionSettings.getDefaultEventDetectionSettings(),
  82.              new ContinueOnEvent());
  83.     }

  84.     /** Protected constructor.
  85.      * @param body central body
  86.      * @param skimmingAltitude skimming altitude at which events are triggered
  87.      * @param secondary provider for the secondary satellite
  88.      * @param detectionSettings detection settings
  89.      * @param handler   event handler to call at event occurrences
  90.      * @since 13.0
  91.      */
  92.     protected InterSatDirectViewDetector(final OneAxisEllipsoid body,
  93.                                          final double skimmingAltitude,
  94.                                          final PVCoordinatesProvider secondary,
  95.                                          final EventDetectionSettings detectionSettings,
  96.                                          final EventHandler handler) {
  97.         super(detectionSettings, handler);
  98.         this.body             = body;
  99.         this.skimmingAltitude = skimmingAltitude;
  100.         this.secondary        = secondary;
  101.     }

  102.     /** Get the central body.
  103.      * @return central body
  104.      */
  105.     public OneAxisEllipsoid getCentralBody() {
  106.         return body;
  107.     }

  108.     /** Get the skimming altitude.
  109.      * @return skimming altitude at which events are triggered
  110.      * @since 12.0
  111.      */
  112.     public double getSkimmingAltitude() {
  113.         return skimmingAltitude;
  114.     }

  115.     /** Get the provider for the secondary satellite.
  116.      * @return provider for the secondary satellite
  117.      */
  118.     public PVCoordinatesProvider getSecondary() {
  119.         return secondary;
  120.     }

  121.     /** {@inheritDoc} */
  122.     @Override
  123.     protected InterSatDirectViewDetector create(final EventDetectionSettings detectionSettings,
  124.                                                 final EventHandler newHandler) {
  125.         return new InterSatDirectViewDetector(body, skimmingAltitude, secondary,
  126.                                               detectionSettings, newHandler);
  127.     }

  128.     /**
  129.      * Setup the skimming altitude.
  130.      * <p>
  131.      * The skimming altitude is the lowest altitude of the path between satellites
  132.      * at which events should be triggered. If set to 0.0, events are triggered
  133.      * exactly when the path passes just at central body limb.
  134.      * </p>
  135.      * @param newSkimmingAltitude skimming altitude (m)
  136.      * @return a new detector with updated configuration (the instance is not changed)
  137.      * @see #getSkimmingAltitude()
  138.      * @since 12.0
  139.      */
  140.     public InterSatDirectViewDetector withSkimmingAltitude(final double newSkimmingAltitude) {
  141.         return new InterSatDirectViewDetector(body, newSkimmingAltitude, secondary,
  142.                                               getDetectionSettings(), getHandler());
  143.     }

  144.     /** {@inheritDoc}
  145.      * <p>
  146.      * The {@code g} function of this detector is the difference between the minimum
  147.      * altitude of intermediate points along the line of sight between satellites and the
  148.      * {@link #getSkimmingAltitude() skimming altitude}. It is therefore positive when
  149.      * all intermediate points are above the skimming altitude, meaning satellites can see
  150.      * each other and it is negative when some intermediate points (which may be either
  151.      * endpoints) dive below this altitude, meaning satellites cannot see each other.
  152.      * </p>
  153.      */
  154.     @Override
  155.     public double g(final SpacecraftState state) {

  156.         // get the lowest point between primary and secondary
  157.         final AbsoluteDate  date   = state.getDate();
  158.         final Frame         frame  = body.getBodyFrame();
  159.         final GeodeticPoint lowest = body.lowestAltitudeIntermediate(state.getPosition(frame),
  160.                                                                      secondary.getPosition(date, frame));

  161.         // compute switching function value as altitude difference
  162.         return lowest.getAltitude() - skimmingAltitude;

  163.     }

  164. }